refactor: make mapModules more easily readable
This commit is contained in:
parent
b606eb4b44
commit
7ae552d698
1 changed files with 4 additions and 2 deletions
|
@ -16,7 +16,7 @@ lib.makeExtensible (_: rec {
|
||||||
|
|
||||||
mapModules = f: dir:
|
mapModules = f: dir:
|
||||||
let
|
let
|
||||||
filter = name: type:
|
filterModules = name: type:
|
||||||
let
|
let
|
||||||
isPublic = !(lib.hasPrefix "_" name);
|
isPublic = !(lib.hasPrefix "_" name);
|
||||||
isSomething = type != null;
|
isSomething = type != null;
|
||||||
|
@ -30,6 +30,8 @@ lib.makeExtensible (_: rec {
|
||||||
in
|
in
|
||||||
isPublic && isSomething && isModule;
|
isPublic && isSomething && isModule;
|
||||||
|
|
||||||
|
modulesInDir = lib.filterAttrs filterModules (builtins.readDir dir);
|
||||||
|
|
||||||
mkModule = name: _:
|
mkModule = name: _:
|
||||||
let
|
let
|
||||||
path = "${toString dir}/${name}";
|
path = "${toString dir}/${name}";
|
||||||
|
@ -40,7 +42,7 @@ lib.makeExtensible (_: rec {
|
||||||
in
|
in
|
||||||
lib.nameValuePair normalizedName (f path);
|
lib.nameValuePair normalizedName (f path);
|
||||||
in
|
in
|
||||||
lib.mapAttrs' mkModule (lib.filterAttrs filter (builtins.readDir dir));
|
lib.mapAttrs' mkModule modulesInDir;
|
||||||
|
|
||||||
mapModules' = f: dir: lib.attrValues (mapModules f dir);
|
mapModules' = f: dir: lib.attrValues (mapModules f dir);
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue