{ 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); }