Ensure normalized root has nixDir set

This commit is contained in:
Archit Gupta 2023-04-15 05:07:03 -07:00
parent 7d6c750790
commit 28d5f5a5b4

View File

@ -61,10 +61,7 @@ let
(p: import (path + (if pathExists (p: import (path + (if pathExists
(path + "/+${p}.nix") then "/+${p}.nix" else "/${p}.nix"))); (path + "/+${p}.nix") then "/+${p}.nix" else "/${p}.nix")));
autoloadAttr = src: root: attr: autoloadAttr = nixDir: attr:
let
nixDir = root.nixDir or (src + /nix);
in
if pathExists (nixDir + "/${attr}.nix") if pathExists (nixDir + "/${attr}.nix")
then import (nixDir + "/${attr}.nix") then import (nixDir + "/${attr}.nix")
else if pathExists (nixDir + "/${attr}/default.nix") else if pathExists (nixDir + "/${attr}/default.nix")
@ -95,8 +92,8 @@ let
"outputs" "outputs"
]; ];
genAutoAttrs = src: root: genAutoAttrs = nixDir:
filterAttrs (_: v: v != null) (genAttrs autoAttrs (autoloadAttr src root)); filterAttrs (_: v: v != null) (genAttrs autoAttrs (autoloadAttr nixDir));
ensureFn = v: if isFunction v then v else _: v; ensureFn = v: if isFunction v then v else _: v;
@ -194,12 +191,14 @@ let
root' = root' =
let let
rootWithAuto = (genAutoAttrs src root) // root; nixDir = root.nixDir or (src + ./nix);
rootWithAuto = (genAutoAttrs nixDir) // root;
in in
normalizeModule rootWithAuto // { normalizeModule rootWithAuto // {
systems = applyParams rootWithAuto.systems or systems.linuxDefault; systems = applyParams rootWithAuto.systems or systems.linuxDefault;
perSystem = ensureFn rootWithAuto.perSystem or (_: { }); perSystem = ensureFn rootWithAuto.perSystem or (_: { });
outputs = applyParams rootWithAuto.outputs or { }; outputs = applyParams rootWithAuto.outputs or { };
inherit nixDir;
}; };
merged = foldl mergeModules moduleDefaults merged = foldl mergeModules moduleDefaults