yazi: remove assertions (#6817)

Contains IFD and unnecessarily restricts user's configuration.
This commit is contained in:
Austin Horstman 2025-04-14 01:18:50 -07:00 committed by GitHub
parent e980d0e0e2
commit 85dd758c70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -276,49 +276,5 @@ in
) cfg.plugins)
]
);
assertions =
let
mkAsserts =
opt: requiredFiles:
mapAttrsToList (
name: value:
let
isDir = lib.pathIsDirectory "${value}";
msgNotDir = optionalString (!isDir) "The path or package should be a directory, not a single file.";
isFileMissing =
file: !(lib.pathExists "${value}/${file}") || lib.pathIsDirectory "${value}/${file}";
missingFiles = lib.filter isFileMissing requiredFiles;
msgFilesMissing = optionalString (
missingFiles != [ ]
) "The ${singularOpt} is missing these files: ${toString missingFiles}";
singularOpt = lib.removeSuffix "s" opt;
isPluginValid =
opt == "plugins" && (lib.any (file: lib.pathExists "${value}/${file}") requiredFiles);
isValid = if opt == "plugins" then isPluginValid else missingFiles == [ ];
in
{
assertion = isDir && isValid;
message = ''
Value at `programs.yazi.${opt}.${name}` is not a valid yazi ${singularOpt}.
${msgNotDir}
${msgFilesMissing}
Evaluated value: `${value}`
'';
}
) cfg.${opt};
in
(mkAsserts "flavors" [
"flavor.toml"
"tmtheme.xml"
"README.md"
"preview.png"
"LICENSE"
"LICENSE-tmtheme"
])
++ (mkAsserts "plugins" [
"init.lua"
"main.lua"
]);
};
}