This commit is contained in:
parent
362fba1385
commit
fc4d569886
6 changed files with 70 additions and 54 deletions
|
@ -1,18 +1,22 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
lib = pkgs.lib;
|
||||
foldersWithNix =
|
||||
path:
|
||||
let
|
||||
folders = lib.attrNames (lib.filterAttrs (n: t: t == "directory") (builtins.readDir path));
|
||||
isFolderWithDefaultNix = folder: lib.pathExists (lib.path.append path "./${folder}/default.nix");
|
||||
in
|
||||
lib.filter isFolderWithDefaultNix folders;
|
||||
inherit (pkgs.lib)
|
||||
attrNames
|
||||
filterAttrs
|
||||
filter
|
||||
pathExists
|
||||
path
|
||||
;
|
||||
isFolderWithFile =
|
||||
fileName: basePath: folderName:
|
||||
(pathExists (path.append basePath "./${folderName}/${fileName}.nix"));
|
||||
getSubDirs = base: attrNames (filterAttrs (n: t: t == "directory") (builtins.readDir base));
|
||||
foldersWithNix = base: filter (isFolderWithFile "default.nix") (getSubDirs base);
|
||||
|
||||
in
|
||||
{
|
||||
inherit foldersWithNix;
|
||||
inherit isFolderWithFile foldersWithNix;
|
||||
|
||||
loadSubmodulesFrom =
|
||||
path: map (folder: lib.path.append path "./${folder}/default.nix") (foldersWithNix path);
|
||||
basePath: map (folder: path.append basePath "./${folder}/default.nix") (foldersWithNix basePath);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue