22 lines
599 B
Nix
22 lines
599 B
Nix
{ pkgs, ... }:
|
|
let
|
|
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 isFolderWithFile foldersWithNix;
|
|
|
|
loadSubmodulesFrom =
|
|
basePath: map (folder: path.append basePath "./${folder}/default.nix") (foldersWithNix basePath);
|
|
}
|