Export autoloadAttr

This commit is contained in:
Archit Gupta 2023-04-15 04:41:27 -07:00
parent 867bf2ba6e
commit bbe8e3a442

View File

@ -11,7 +11,7 @@ let
optionalString parseDrvName pathExists pipe recursiveUpdate removePrefix optionalString parseDrvName pathExists pipe recursiveUpdate removePrefix
removeSuffix zipAttrsWith; removeSuffix zipAttrsWith;
exports = { inherit mkFlake loadNixDir systems; }; exports = { inherit mkFlake loadNixDir systems autoloadAttr; };
baseModule = src: inputs: root: { baseModule = src: inputs: root: {
withOverlays = params: [ withOverlays = params: [
@ -47,10 +47,10 @@ let
}; };
}; };
autoAttrs = src: root: autoloadAttr = src: root: attr:
let let
nixDir = root.nixDir or (src + /nix); nixDir = root.nixDir or (src + /nix);
loadAttr = attr: 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")
@ -58,7 +58,8 @@ let
else if pathExists (nixDir + "/${attr}") else if pathExists (nixDir + "/${attr}")
then loadNixDir (nixDir + "/${attr}") then loadNixDir (nixDir + "/${attr}")
else null; else null;
attrs = [
autoAttrs = [
"withOverlay" "withOverlay"
"withOverlays" "withOverlays"
"package" "package"
@ -79,8 +80,9 @@ let
"perSystem" "perSystem"
"outputs" "outputs"
]; ];
in
filterAttrs (_: v: v != null) (genAttrs attrs loadAttr); genAutoAttrs = src: root:
filterAttrs (_: v: v != null) (genAttrs autoAttrs (autoloadAttr src root));
mkFlake = src: inputs: root: mkFlake = src: inputs: root:
let let
@ -143,7 +145,7 @@ let
root' = root' =
let let
rootWithAuto = (autoAttrs src root) // root; rootWithAuto = (genAutoAttrs src root) // root;
in in
normalizeModule rootWithAuto // { normalizeModule rootWithAuto // {
systems = applyParams rootWithAuto.systems or systems.linuxDefault; systems = applyParams rootWithAuto.systems or systems.linuxDefault;