Rename directory flake to flake-parts

This commit is contained in:
SebastianStork 2025-09-23 20:49:01 +02:00
parent 8cdb87769c
commit 121d7364f7
7 changed files with 6 additions and 6 deletions

59
flake-parts/hosts.nix Normal file
View file

@ -0,0 +1,59 @@
{
inputs,
self,
lib,
...
}:
let
mkHost =
hostName:
inputs.nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs self; };
modules =
let
hostFiles =
"${self}/hosts/${hostName}"
|> lib.filesystem.listFilesRecursive
|> lib.filter (lib.hasSuffix ".nix");
userFiles =
"${self}/users"
|> builtins.readDir
|> lib.filterAttrs (_: type: type == "directory")
|> lib.attrNames
|> map (user: "${self}/users/${user}/@${hostName}")
|> lib.filter (path: lib.pathExists path);
in
[
{ networking = { inherit hostName; }; }
"${self}/hosts/common.nix"
]
++ hostFiles
++ userFiles;
};
mkDeployNode = hostname: {
inherit hostname;
sshUser = "root";
profiles.system.path =
inputs.deploy-rs.lib.x86_64-linux.activate.nixos
self.nixosConfigurations.${hostname};
};
in
{
flake = {
nixosConfigurations =
"${self}/hosts"
|> builtins.readDir
|> lib.filterAttrs (_: type: type == "directory")
|> lib.mapAttrs (name: _: mkHost name);
deploy.nodes =
"${self}/hosts"
|> builtins.readDir
|> lib.filterAttrs (_: type: type == "directory")
|> lib.mapAttrs (name: _: mkDeployNode name);
checks = lib.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib;
};
}