lib: rename defaultImports
This commit is contained in:
parent
e2172c8410
commit
3bc16596f7
1 changed files with 26 additions and 10 deletions
|
@ -42,21 +42,37 @@ let
|
||||||
in
|
in
|
||||||
map fullPath (attrNames (readDir overlayDir));
|
map fullPath (attrNames (readDir overlayDir));
|
||||||
|
|
||||||
defaultImports = dir:
|
/**
|
||||||
|
Synopsis: importDefaults _path_
|
||||||
|
|
||||||
|
Recursively import the subdirs of _path_ containing a default.nix.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
let profiles = importDefaults ./profiles; in
|
||||||
|
assert profiles ? core.default; 0
|
||||||
|
**/
|
||||||
|
importDefaults = dir:
|
||||||
let
|
let
|
||||||
filtered = filterAttrs
|
imports =
|
||||||
(n: v: v == "directory" && pathExists "${dir}/${n}/default.nix")
|
let
|
||||||
(readDir dir);
|
files = readDir dir;
|
||||||
|
|
||||||
|
p = n: v:
|
||||||
|
v == "directory"
|
||||||
|
&& pathExists "${dir}/${n}/default.nix";
|
||||||
|
in
|
||||||
|
filterAttrs p files;
|
||||||
|
|
||||||
|
f = n: _:
|
||||||
|
{ default = import "${dir}/${n}/default.nix"; }
|
||||||
|
// importDefaults "${dir}/${n}";
|
||||||
in
|
in
|
||||||
mapAttrs
|
mapAttrs f imports;
|
||||||
(n: v: {
|
|
||||||
default = import "${dir}/${n}/default.nix";
|
|
||||||
} // defaultImports "${dir}/${n}")
|
|
||||||
filtered;
|
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit defaultImports mapFilterAttrs genAttrs' pkgImport pathsToImportedAttrs;
|
inherit importDefaults mapFilterAttrs genAttrs' pkgImport
|
||||||
|
pathsToImportedAttrs;
|
||||||
|
|
||||||
overlays = pathsToImportedAttrs overlayPaths;
|
overlays = pathsToImportedAttrs overlayPaths;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue