output: allow to have host defined in subdirectory
This commit is contained in:
parent
78ab704ca3
commit
f4772d075a
1 changed files with 8 additions and 7 deletions
15
outputs.nix
15
outputs.nix
|
@ -22,22 +22,22 @@ self = {
|
|||
filePaths = lib.pipe ./hosts [
|
||||
builtins.readDir
|
||||
( lib.filterAttrs (name: type:
|
||||
# filter out non-nix files
|
||||
type == "regular"
|
||||
# filter out files that don't end in .nix
|
||||
&& lib.hasSuffix ".nix" name
|
||||
( # regular .nix files
|
||||
(type == "regular" && lib.hasSuffix ".nix" name)
|
||||
|| # directories that contain a default.nix file
|
||||
(type == "directory" && builtins.pathExists "${./hosts}/${name}/default.nix")
|
||||
)
|
||||
# filter out files that start with .
|
||||
&& !lib.hasPrefix "." name
|
||||
))
|
||||
(lib.mapAttrsToList (name: _: name))
|
||||
];
|
||||
nixosSystem = import "${inputs.nixpkgs}/nixos/lib/eval-config.nix";
|
||||
in
|
||||
# mapped list of nix file paths to attrSet with initialized NixOS configurations,
|
||||
# whose names are derived from file names
|
||||
lib.pipe filePaths [
|
||||
(builtins.map (name: {
|
||||
name = builtins.substring 0 (builtins.stringLength name - 4) name;
|
||||
(builtins.mapAttrs (name: type: {
|
||||
name = if type == "directory" then name else builtins.substring 0 (builtins.stringLength name - 4) name;
|
||||
value = nixosSystem {
|
||||
inherit lib;
|
||||
modules = [
|
||||
|
@ -53,6 +53,7 @@ self = {
|
|||
specialArgs = { inherit self inputs; };
|
||||
};
|
||||
}))
|
||||
builtins.attrValues
|
||||
builtins.listToAttrs
|
||||
];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue