chore(hooks): enforce enable option on all home modules
This commit is contained in:
@@ -5,7 +5,26 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
{
|
let
|
||||||
|
moduleDirs = lib.filterAttrs (_: v: v == "directory") (builtins.readDir ./.);
|
||||||
|
dirHasEnableOption =
|
||||||
|
name:
|
||||||
|
let
|
||||||
|
nixFiles = lib.filterAttrs (n: v: v == "regular" && lib.hasSuffix ".nix" n) (
|
||||||
|
builtins.readDir ./${name}
|
||||||
|
);
|
||||||
|
in
|
||||||
|
!(builtins.pathExists ./${name}/default.nix)
|
||||||
|
|| lib.any (f: lib.hasInfix "mkEnableOption" (builtins.readFile ./${name}/${f})) (
|
||||||
|
builtins.attrNames nixFiles
|
||||||
|
);
|
||||||
|
withoutEnableOption = builtins.attrNames (
|
||||||
|
lib.filterAttrs (name: _: !dirHasEnableOption name) moduleDirs
|
||||||
|
);
|
||||||
|
in
|
||||||
|
lib.throwIf (withoutEnableOption != [ ])
|
||||||
|
"home modules missing enable option: ${lib.concatStringsSep ", " withoutEnableOption}"
|
||||||
|
{
|
||||||
options = {
|
options = {
|
||||||
host.username = lib.mkOption {
|
host.username = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
@@ -34,4 +53,4 @@
|
|||||||
readOnly = true;
|
readOnly = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user