feat: isolate deploy module

This commit is contained in:
Jermeiah S 2025-06-19 16:07:55 -04:00
parent bb141b7a71
commit 6becf62164
No known key found for this signature in database
3 changed files with 29 additions and 19 deletions

View file

@ -6,21 +6,25 @@ let
nixpkgs nixpkgs
nixos-anywhere nixos-anywhere
; ;
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
genNode = genNode =
hostName: nixosCfg: hostName: nixosCfg:
let let
# inherit (self.hosts.${hostName}) address hostPlatform remoteBuild; deploy = nixosCfg.config.deploy;
# inherit (deploy-rs.lib.${hostPlatform}) activate; system = nixosCfg.pkgs.system;
system = self.nixosConfigurations."${hostName}".pkgs.system;
address = self.nixosConfigurations."${hostName}".config.deploy.address;
in in
{ {
# inherit address; hostname = deploy.address;
hostname = address; profiles.system.path = deploy-rs.lib.${system}.activate.nixos nixosCfg;
profiles.system.path = deploy-rs.lib.${system}.activate.nixos self.nixosConfigurations.${hostName};
}; };
# Filter out nodes where deploy.enable != true
deployableNodes = lib.filterAttrs (hostName: nixosCfg: nixosCfg.config.deploy.enable or false) (
self.nixosConfigurations or { }
);
in in
{ {
perSystem = perSystem =
@ -44,13 +48,12 @@ in
deploy = deploy-rs.apps.${system}.deploy-rs; deploy = deploy-rs.apps.${system}.deploy-rs;
}; };
}; };
flake = {
deploy = { flake.deploy = {
autoRollback = false; autoRollback = false;
magicRollback = true; magicRollback = true;
user = "root"; user = "root";
remoteBuild = true; remoteBuild = true;
nodes = lib.mapAttrs genNode (self.nixosConfigurations or { }); nodes = lib.mapAttrs genNode deployableNodes;
};
}; };
} }

View file

@ -0,0 +1,10 @@
{ lib, config, ... }:
{
options.deploy = {
enable = lib.mkEnableOption "enable deployrs module";
address = lib.mkOption {
type = lib.types.str;
default = config.networking.hostName;
};
};
}

View file

@ -1,9 +1,6 @@
{ lib, config, ... }: { lib, config, ... }:
{ {
options.deploy.address = lib.mkOption {
type = lib.types.str;
default = config.networking.hostName;
};
config = { config = {
services.openssh.enable = true; services.openssh.enable = true;
security = { security = {