mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-08-21 14:47:18 -05:00
26 lines
720 B
Nix
26 lines
720 B
Nix
|
{...}: let
|
||
|
inherit (builtins) concatLists attrValues mapAttrs elemAt match readDir;
|
||
|
in rec {
|
||
|
# https://github.com/balsoft/nixos-config/blob/73cc2c3a8bb62a9c3980a16ae70b2e97af6e1abd/flake.nix#L109-L120
|
||
|
findModulesList = dir:
|
||
|
concatLists (attrValues (mapAttrs
|
||
|
(name: type:
|
||
|
if type == "regular"
|
||
|
then [
|
||
|
{
|
||
|
name = elemAt (match "(.*)\\.nix" name) 0;
|
||
|
value = dir + "/${name}";
|
||
|
}
|
||
|
]
|
||
|
else if
|
||
|
(readDir (dir + "/${name}"))
|
||
|
? "default.nix"
|
||
|
then [
|
||
|
{
|
||
|
inherit name;
|
||
|
value = dir + "/${name}";
|
||
|
}
|
||
|
]
|
||
|
else findModulesList (dir + "/${name}")) (readDir dir)));
|
||
|
}
|