changed imports to mkModules

This commit is contained in:
Bryan Ramos 2024-11-07 15:41:50 -05:00
parent 649d9e83b6
commit 5c3d410aa0
Signed by: bryan
GPG key ID: 6ABDCD144D6643C8
34 changed files with 67 additions and 448 deletions

View file

@ -1,6 +1,35 @@
let
mkModules = dir: isRoot:
let
entries = builtins.readDir dir;
names = builtins.attrNames entries;
isModuleDir = path:
builtins.pathExists path &&
builtins.readFileType path == "directory" &&
builtins.baseNameOf path != "config";
isModule = file: file == "default.nix";
isNix = file: builtins.match ".*\\.nix" file != null && file != "default.nix";
in
builtins.concatMap (name:
let
path = "${dir}/${name}";
in
if isModuleDir path then
mkModules path false
else if isModule name && !isRoot then
[ dir ]
else if isNix name then
[ path ]
else
[]
) names;
in
{
imports = [
./configs
./modules
];
./config
] ++ mkModules ./. true;
}