deployments/common/deployment.nix

38 lines
1.1 KiB
Nix
Raw Normal View History

{ inputs, deployment-hosts, description, enable-rollback ? true, ... }:
2024-03-23 14:23:28 -07:00
with inputs.nixpkgs.lib;
let
network-config = {
nixpkgs = inputs.nixpkgs;
network = {
inherit description;
enableRollback = enable-rollback;
2021-12-09 09:12:54 -08:00
2024-03-23 14:23:28 -07:00
storage.legacy = { databasefile = "~/.nixops/deployments.nixops"; };
};
};
2024-03-23 14:23:28 -07:00
host-config = hostname:
inputs.fudo-nixos.nixopsHostConfigurations.${hostname};
2024-03-23 14:23:28 -07:00
host-ip = hostname: domain:
let zone-hosts = inputs.fudo-entities.entities.zones.${domain}.hosts;
in zone-hosts.${hostname}.ipv4-address;
2021-11-29 22:08:44 -08:00
2024-03-23 14:23:28 -07:00
host-uber-secrets = hostname:
{ config, ... }:
let uber-secrets = config.fudo.secrets.files.host-filesystem-keys;
in {
config.deployment.keys = mkIf (hasAttr hostname uber-secrets) (mapAttrs
(secret: secret-file: {
keyFile = secret-file;
user = "root";
permissions = "0400";
}) uber-secrets.${hostname});
};
2021-11-29 22:08:44 -08:00
in network-config // (mapAttrs (hostname: hostOpts: {
2024-03-23 14:23:28 -07:00
imports = [ (host-config hostname) (host-uber-secrets hostname) ];
2021-11-29 22:08:44 -08:00
deployment.targetHost = host-ip hostname hostOpts.domain;
}) deployment-hosts)