mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 07:04:17 +00:00
yazi: Assert that plugins have valid structure
This commit is contained in:
parent
5ccc3d6739
commit
340b98c0ab
1 changed files with 21 additions and 2 deletions
|
@ -209,12 +209,31 @@ in {
|
|||
else
|
||||
"yazi/plugins/${pluginName}.yazi";
|
||||
|
||||
mkPluginLink = pluginName: pluginPackage: {
|
||||
mkPluginLink = pluginName: pluginPackageOrPath: {
|
||||
name = ensureSuffix pluginName;
|
||||
value.source = pluginPackage;
|
||||
value.source = pluginPackageOrPath;
|
||||
};
|
||||
|
||||
pluginLinks = mapAttrs' mkPluginLink cfg.plugins;
|
||||
in pluginLinks);
|
||||
|
||||
assertions = (mapAttrsToList (pluginName: pluginPackageOrPath:
|
||||
let
|
||||
isDir = pathIsDirectory "${pluginPackageOrPath}";
|
||||
hasInitLua = pathExists "${pluginPackageOrPath}/init.lua"
|
||||
&& !(pathIsDirectory "${pluginPackageOrPath}/init.lua");
|
||||
in {
|
||||
assertion = isDir && hasInitLua;
|
||||
message =
|
||||
"Value at `programs.yazi.plugins.${pluginName}` is not a valid yazi plugin."
|
||||
+ (optionalString (!isDir) ''
|
||||
|
||||
The path or package should be a directory, not a single file.'')
|
||||
+ (optionalString (!hasInitLua) ''
|
||||
|
||||
The path or package must contain a file `init.lua`.'') + ''
|
||||
|
||||
Evaluated value: `${pluginPackageOrPath}`'';
|
||||
}) cfg.plugins);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue