feat: isolate deploy module
This commit is contained in:
parent
bb141b7a71
commit
6becf62164
3 changed files with 29 additions and 19 deletions
|
|
@ -6,21 +6,25 @@ let
|
|||
nixpkgs
|
||||
nixos-anywhere
|
||||
;
|
||||
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
genNode =
|
||||
hostName: nixosCfg:
|
||||
let
|
||||
# inherit (self.hosts.${hostName}) address hostPlatform remoteBuild;
|
||||
# inherit (deploy-rs.lib.${hostPlatform}) activate;
|
||||
system = self.nixosConfigurations."${hostName}".pkgs.system;
|
||||
address = self.nixosConfigurations."${hostName}".config.deploy.address;
|
||||
deploy = nixosCfg.config.deploy;
|
||||
system = nixosCfg.pkgs.system;
|
||||
in
|
||||
{
|
||||
# inherit address;
|
||||
hostname = address;
|
||||
profiles.system.path = deploy-rs.lib.${system}.activate.nixos self.nixosConfigurations.${hostName};
|
||||
hostname = deploy.address;
|
||||
profiles.system.path = deploy-rs.lib.${system}.activate.nixos nixosCfg;
|
||||
};
|
||||
|
||||
# Filter out nodes where deploy.enable != true
|
||||
deployableNodes = lib.filterAttrs (hostName: nixosCfg: nixosCfg.config.deploy.enable or false) (
|
||||
self.nixosConfigurations or { }
|
||||
);
|
||||
|
||||
in
|
||||
{
|
||||
perSystem =
|
||||
|
|
@ -44,13 +48,12 @@ in
|
|||
deploy = deploy-rs.apps.${system}.deploy-rs;
|
||||
};
|
||||
};
|
||||
flake = {
|
||||
deploy = {
|
||||
autoRollback = false;
|
||||
magicRollback = true;
|
||||
user = "root";
|
||||
remoteBuild = true;
|
||||
nodes = lib.mapAttrs genNode (self.nixosConfigurations or { });
|
||||
};
|
||||
|
||||
flake.deploy = {
|
||||
autoRollback = false;
|
||||
magicRollback = true;
|
||||
user = "root";
|
||||
remoteBuild = true;
|
||||
nodes = lib.mapAttrs genNode deployableNodes;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
10
modules/nixos/common/deployrs.nix
Normal file
10
modules/nixos/common/deployrs.nix
Normal 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;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
{ lib, config, ... }:
|
||||
{
|
||||
options.deploy.address = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = config.networking.hostName;
|
||||
};
|
||||
|
||||
config = {
|
||||
services.openssh.enable = true;
|
||||
security = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue