refactor(systems): pull out inline modules

This commit is contained in:
arcnmx 2024-02-19 17:34:39 -08:00
parent 35177ce911
commit b339ef65f6
20 changed files with 296 additions and 218 deletions

41
modules/system/deploy.nix Normal file
View file

@ -0,0 +1,41 @@
{
name,
config,
lib,
inputs,
...
}: let
inherit (lib.modules) mkIf mkOptionDefault;
in {
options = let
inherit (inputs.self.lib.lib) json;
inherit (lib.types) nullOr;
inherit (lib.options) mkOption;
in {
deploy = mkOption {
type = nullOr json.types.attrs;
};
};
config = {
deploy = let
nixos = config.built;
in {
sshUser = mkOptionDefault "root";
user = mkOptionDefault "root";
sshOpts = mkIf (config.type == "NixOS") (
mkOptionDefault ["-p" "${builtins.toString (builtins.head nixos.config.services.openssh.ports)}"]
);
autoRollback = mkOptionDefault true;
magicRollback = mkOptionDefault true;
fastConnection = mkOptionDefault false;
hostname = mkOptionDefault "${name}.local.gensokyo.zone";
profiles.system = {
user = "root";
path = let
inherit (inputs.self.legacyPackages.${config.system}.deploy-rs) activate;
in
activate.nixos nixos;
};
};
};
}