Only autoload from ./nix or dir specified by nixDir

This commit is contained in:
Archit Gupta 2023-04-15 04:18:54 -07:00
parent 58503515fb
commit 867bf2ba6e

View File

@ -47,21 +47,16 @@ let
}; };
}; };
autoAttrs = src: autoAttrs = src: root:
let let
nixDir = root.nixDir or (src + /nix);
loadAttr = attr: loadAttr = attr:
if pathExists (src + "/nix/${attr}.nix") if pathExists (nixDir + "/${attr}.nix")
then import (src + "/nix/${attr}.nix") then import (nixDir + "/${attr}.nix")
else if pathExists (src + "/nix/${attr}/default.nix") else if pathExists (nixDir + "/${attr}/default.nix")
then import (src + "/nix/${attr}") then import (nixDir + "/${attr}")
else if pathExists (src + "/nix/${attr}") else if pathExists (nixDir + "/${attr}")
then loadNixDir (src + "/nix/${attr}") then loadNixDir (nixDir + "/${attr}")
else if pathExists (src + "/${attr}.nix")
then import (src + "/${attr}.nix")
else if pathExists (src + "/${attr}/default.nix")
then import (src + "/${attr}")
else if pathExists (src + "/${attr}")
then loadNixDir (src + "/${attr}")
else null; else null;
attrs = [ attrs = [
"withOverlay" "withOverlay"
@ -148,7 +143,7 @@ let
root' = root' =
let let
rootWithAuto = (autoAttrs src) // root; rootWithAuto = (autoAttrs src root) // root;
in in
normalizeModule rootWithAuto // { normalizeModule rootWithAuto // {
systems = applyParams rootWithAuto.systems or systems.linuxDefault; systems = applyParams rootWithAuto.systems or systems.linuxDefault;