lib: rename defaultImports

This commit is contained in:
Timothy DeHerrera 2021-02-06 13:30:17 -07:00
parent e2172c8410
commit 3bc16596f7
No known key found for this signature in database
GPG key ID: 8985725DB5B0C122

View file

@ -42,21 +42,37 @@ let
in
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
filtered = filterAttrs
(n: v: v == "directory" && pathExists "${dir}/${n}/default.nix")
(readDir dir);
imports =
let
files = readDir dir;
p = n: v:
v == "directory"
&& pathExists "${dir}/${n}/default.nix";
in
mapAttrs
(n: v: {
default = import "${dir}/${n}/default.nix";
} // defaultImports "${dir}/${n}")
filtered;
filterAttrs p files;
f = n: _:
{ default = import "${dir}/${n}/default.nix"; }
// importDefaults "${dir}/${n}";
in
mapAttrs f imports;
in
{
inherit defaultImports mapFilterAttrs genAttrs' pkgImport pathsToImportedAttrs;
inherit importDefaults mapFilterAttrs genAttrs' pkgImport
pathsToImportedAttrs;
overlays = pathsToImportedAttrs overlayPaths;