Implement nixos-modules/static-page test
All checks were successful
CI / build (push) Successful in 2m40s
All checks were successful
CI / build (push) Successful in 2m40s
This commit is contained in:
parent
c3962b9738
commit
7930f9191d
10 changed files with 180 additions and 15 deletions
|
@ -1,18 +1,26 @@
|
|||
{ 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
|
||||
;
|
||||
# Get a list of all subdirectories of a directory.
|
||||
getSubDirs = base: attrNames (filterAttrs (n: t: t == "directory") (builtins.readDir base));
|
||||
# Check if a folder with a base path and folder name contains a file with a specific name
|
||||
isFolderWithFile =
|
||||
fileName: basePath: folderName:
|
||||
(pathExists (path.append basePath "./${folderName}/${fileName}"));
|
||||
# Get a list of subfolders that contain a default.nix file.
|
||||
foldersWithNix = base: filter (isFolderWithFile "default.nix" base) (getSubDirs base);
|
||||
|
||||
in
|
||||
{
|
||||
inherit foldersWithNix;
|
||||
inherit getSubDirs isFolderWithFile foldersWithNix;
|
||||
|
||||
# Get a list of default.nix files that are nix submodules of the current folder.
|
||||
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