Support "splat" in checks

Signed-off-by: magic_rb <magic_rb@redalder.org>
This commit is contained in:
magic_rb 2024-11-10 19:08:53 +01:00
parent 71f1c4e1e2
commit e99c9e848f
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E

View file

@ -32,6 +32,7 @@ in {
in {
checks = pipe (builtins.readDir ./.) [
(filterAttrs (n: _: n != "default.nix"))
(mapAttrs (n: _: (importDefault (toString ./. + "/" + n))))
(mapAttrs' (n: v: let
newName =
if hasSuffix ".nix" n
@ -39,8 +40,12 @@ in {
else n;
in
nameValuePair newName v))
(mapAttrs (n: _: (importDefault (toString ./. + "/" + n))))
(filterAttrs (_: v: v ? "_type" -> v._type == "if" -> v.condition))
(filterAttrs (_: v: v ? "_type" && v._type == "if" -> v.condition))
(lib.mapAttrsToList nameValuePair)
(lib.foldl (acc: x:
if x.value ? "_type" && x.value._type == "splat"
then acc // x.value.value
else acc // {${x.name} = x.value;}) {})
];
};
}