meta: reorganize nix-os and hosts to single directory nixos

This commit is contained in:
Wroclaw 2025-05-18 18:44:51 +02:00
parent be46e02c61
commit cb05ce5b44
76 changed files with 54 additions and 52 deletions

View file

@ -54,16 +54,17 @@ self = {
];
specialArgs = { inherit self inputs; };
};
baseHostsDir = ./nixos/hosts;
in
# mapped attrset of nix file paths to attrSet with initialized NixOS configurations,
# whose names are derived from file names
lib.pipe ./hosts [
lib.pipe baseHostsDir [
builtins.readDir
# filter out files that are not .nix files, directories with default.nix or starting with . (dot, hidden files)
( lib.filterAttrs (name: type:
(
(type == "regular" && lib.hasSuffix ".nix" name)
|| (type == "directory" && builtins.pathExists "${builtins.toString ./.}/hosts/${name}/default.nix")
|| (type == "directory" && builtins.pathExists (baseHostsDir + "/${name}/default.nix"))
)
&& !lib.hasPrefix "." name
))
@ -71,7 +72,7 @@ self = {
# remove .nix extension
name = if type == "directory" then name else builtins.substring 0 (builtins.stringLength name - 4) name;
# initialize NixOS configuration
value = mkNixosSystem ./hosts/${name};
value = mkNixosSystem (baseHostsDir + "/${name}");
}))
builtins.attrValues
builtins.listToAttrs