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
|
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;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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, ... }:
|
{ 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 = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue