mirror of
https://github.com/nix-community/flakelight.git
synced 2025-06-21 01:57:57 +02:00
Export autoloadAttr
This commit is contained in:
parent
867bf2ba6e
commit
bbe8e3a442
68
default.nix
68
default.nix
@ -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,40 +47,42 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
autoAttrs = src: root:
|
autoloadAttr = src: root: attr:
|
||||||
let
|
let
|
||||||
nixDir = root.nixDir or (src + /nix);
|
nixDir = root.nixDir or (src + /nix);
|
||||||
loadAttr = attr:
|
|
||||||
if pathExists (nixDir + "/${attr}.nix")
|
|
||||||
then import (nixDir + "/${attr}.nix")
|
|
||||||
else if pathExists (nixDir + "/${attr}/default.nix")
|
|
||||||
then import (nixDir + "/${attr}")
|
|
||||||
else if pathExists (nixDir + "/${attr}")
|
|
||||||
then loadNixDir (nixDir + "/${attr}")
|
|
||||||
else null;
|
|
||||||
attrs = [
|
|
||||||
"withOverlay"
|
|
||||||
"withOverlays"
|
|
||||||
"package"
|
|
||||||
"packages"
|
|
||||||
"devTools"
|
|
||||||
"devShell"
|
|
||||||
"devShells"
|
|
||||||
"env"
|
|
||||||
"overlay"
|
|
||||||
"overlays"
|
|
||||||
"apps"
|
|
||||||
"checks"
|
|
||||||
"nixosModules"
|
|
||||||
"nixosConfigurations"
|
|
||||||
"templates"
|
|
||||||
"formatters"
|
|
||||||
"systems"
|
|
||||||
"perSystem"
|
|
||||||
"outputs"
|
|
||||||
];
|
|
||||||
in
|
in
|
||||||
filterAttrs (_: v: v != null) (genAttrs attrs loadAttr);
|
if pathExists (nixDir + "/${attr}.nix")
|
||||||
|
then import (nixDir + "/${attr}.nix")
|
||||||
|
else if pathExists (nixDir + "/${attr}/default.nix")
|
||||||
|
then import (nixDir + "/${attr}")
|
||||||
|
else if pathExists (nixDir + "/${attr}")
|
||||||
|
then loadNixDir (nixDir + "/${attr}")
|
||||||
|
else null;
|
||||||
|
|
||||||
|
autoAttrs = [
|
||||||
|
"withOverlay"
|
||||||
|
"withOverlays"
|
||||||
|
"package"
|
||||||
|
"packages"
|
||||||
|
"devTools"
|
||||||
|
"devShell"
|
||||||
|
"devShells"
|
||||||
|
"env"
|
||||||
|
"overlay"
|
||||||
|
"overlays"
|
||||||
|
"apps"
|
||||||
|
"checks"
|
||||||
|
"nixosModules"
|
||||||
|
"nixosConfigurations"
|
||||||
|
"templates"
|
||||||
|
"formatters"
|
||||||
|
"systems"
|
||||||
|
"perSystem"
|
||||||
|
"outputs"
|
||||||
|
];
|
||||||
|
|
||||||
|
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user