From dec790c589444370ae2de52bfbc5e35111eed598 Mon Sep 17 00:00:00 2001 From: oddlama Date: Wed, 7 Jun 2023 19:48:15 +0200 Subject: [PATCH] chore: update to new agenix-rekey format --- flake.lock | 36 +++++----- hosts/common/core/net.nix | 11 ++- hosts/common/core/system.nix | 2 +- hosts/common/initrd-ssh.nix | 9 +-- hosts/sentinel/acme.nix | 6 +- hosts/sentinel/caddy.nix | 6 +- hosts/sentinel/secrets/loki-basic-auth.age | Bin 415 -> 409 bytes hosts/ward/default.nix | 39 +++++------ hosts/ward/promtail.nix | 66 +++++++++++++++--- ...afana.age => loki-basic-auth-password.age} | 0 hosts/ward/vaultwarden.nix | 6 +- hosts/zackbiene/esphome.nix | 4 +- hosts/zackbiene/home-assistant.nix | 10 +-- hosts/zackbiene/hostapd.nix | 4 +- hosts/zackbiene/mosquitto.nix | 12 ++-- hosts/zackbiene/nginx.nix | 12 ++-- hosts/zackbiene/zigbee2mqtt.nix | 10 +-- modules/extra.nix | 2 +- modules/wireguard.nix | 20 +++--- nix/apps/default.nix | 1 + nix/apps/generate-secrets.nix | 39 +++++++++++ 21 files changed, 195 insertions(+), 100 deletions(-) rename hosts/ward/secrets/{loki-basic-auth-password-grafana.age => loki-basic-auth-password.age} (100%) create mode 100644 nix/apps/generate-secrets.nix diff --git a/flake.lock b/flake.lock index a53d157..6af0e0a 100644 --- a/flake.lock +++ b/flake.lock @@ -31,12 +31,10 @@ ] }, "locked": { - "lastModified": 1684539260, - "narHash": "sha256-lF3+vp2UZwBjzF4pnOKYZrQOCFdnOdtvGmaFIzsaMN4=", - "owner": "oddlama", - "repo": "agenix-rekey", - "rev": "e9a2bad33b7b1634af65cbc809fc31776df41fe5", - "type": "github" + "lastModified": 1686159246, + "narHash": "sha256-6+u3Ed6rsYKJ1gnjt1DoEnxgF6Xmi4qPFUy7OBEiN5E=", + "type": "git", + "url": "file:///root/projects/agenix-rekey" }, "original": { "owner": "oddlama", @@ -119,11 +117,11 @@ ] }, "locked": { - "lastModified": 1685970051, - "narHash": "sha256-F5ZxBD2DeNd+Q0dDKYBhv76kfjVG/X0ccXjSKpa8KdI=", + "lastModified": 1686150639, + "narHash": "sha256-QHorMn3tgvCE0BM4QlNb/7vuquz11cS2ke1GSfmgiPo=", "owner": "nix-community", "repo": "disko", - "rev": "29d632d7e8fa86f937153ecdfd7d768411001d2d", + "rev": "f1178c6e72b7d8ab2b55990397969324822275eb", "type": "github" }, "original": { @@ -210,11 +208,11 @@ ] }, "locked": { - "lastModified": 1685885003, - "narHash": "sha256-+OB0EvZBfGvnlTGg6mtyUCqkMnUp9DkmRUU4d7BZBVE=", + "lastModified": 1686142265, + "narHash": "sha256-IP0xPa0VYqxCzpqZsg3iYGXarUF+4r2zpkhwdHy9WsM=", "owner": "nix-community", "repo": "home-manager", - "rev": "607d8fad96436b134424b9935166a7cd0884003e", + "rev": "39c7d0a97a77d3f31953941767a0822c94dc01f5", "type": "github" }, "original": { @@ -260,11 +258,11 @@ ] }, "locked": { - "lastModified": 1685384827, - "narHash": "sha256-lEEMXGKQY5cUWO9vS08a5VLPbVAJm6xGBTd3Cnfg99c=", + "lastModified": 1686092477, + "narHash": "sha256-ewXevzxR3FGhI5ip1QX+jCAQW2En9BTwBI9+kGip9DA=", "owner": "astro", "repo": "microvm.nix", - "rev": "3683f43a37568fbc14bdc1c952acb41b0bb09a01", + "rev": "c6416c6b9fed22b71f526720cb120b0218c51b62", "type": "github" }, "original": { @@ -348,7 +346,7 @@ "nixpkgs": { "locked": { "lastModified": 1685290091, - "narHash": "sha256-eJ4hOd5fA8i9uhpPFrpjLAb09wqfB+NH9utHh0PGD4k=", + "narHash": "sha256-Shhg4EstYivzF10RuNDUKw3KGQOS5e7S7yHFnWuJQSI=", "type": "git", "url": "file:///root/projects/nixpkgs-test" }, @@ -388,11 +386,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1685970613, - "narHash": "sha256-sMbR4zPciUfQ6YHt6GNVxT/yhWJKngvZo8qHzYkaU6E=", + "lastModified": 1686050334, + "narHash": "sha256-R0mczWjDzBpIvM3XXhO908X5e2CQqjyh/gFbwZk/7/Q=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "a117a1cd2c280bf8d499f26370fddfe1923e75e6", + "rev": "6881eb2ae5d8a3516e34714e7a90d9d95914c4dc", "type": "github" }, "original": { diff --git a/hosts/common/core/net.nix b/hosts/common/core/net.nix index ed1ddb6..20575cc 100644 --- a/hosts/common/core/net.nix +++ b/hosts/common/core/net.nix @@ -15,7 +15,16 @@ ; in { # TODO needed until https://github.com/NixOS/nixpkgs/issues/236146 is resolved - boot.initrd.network.flushBeforeStage2 = true; + boot.initrd.systemd = { + services.systemd-networkd = { + before = ["initrd-switch-root.target"]; + conflicts = ["initrd-switch-root.target"]; + }; + sockets.systemd-networkd = { + before = ["initrd-switch-root.target"]; + conflicts = ["initrd-switch-root.target"]; + }; + }; networking = { hostName = nodeName; diff --git a/hosts/common/core/system.nix b/hosts/common/core/system.nix index ee3643c..3391757 100644 --- a/hosts/common/core/system.nix +++ b/hosts/common/core/system.nix @@ -343,7 +343,7 @@ // lib.optionalAttrs (nodePath != null && lib.pathExists local) {inherit local;}; # Setup secret rekeying parameters - rekey = { + age.rekey = { inherit (inputs.self.secretsConfig) masterIdentities diff --git a/hosts/common/initrd-ssh.nix b/hosts/common/initrd-ssh.nix index 0dbb0fe..ee0122e 100644 --- a/hosts/common/initrd-ssh.nix +++ b/hosts/common/initrd-ssh.nix @@ -4,13 +4,14 @@ nodePath, ... }: { - rekey.secrets.initrd_host_ed25519_key.file = nodePath + "/secrets/initrd_host_ed25519_key.age"; + # TODO generate script + age.secrets.initrd_host_ed25519_key.file = nodePath + "/secrets/initrd_host_ed25519_key.age"; boot.initrd.network.enable = true; boot.initrd.network.ssh = { enable = true; port = 4; - hostKeys = [config.rekey.secrets.initrd_host_ed25519_key.path]; + hostKeys = [config.age.secrets.initrd_host_ed25519_key.path]; }; # Make sure that there is always a valid initrd hostkey available that can be installed into @@ -21,8 +22,8 @@ # for the first time, and the secrets were rekeyed for the the new host identity. system.activationScripts.agenixEnsureInitrdHostkey = { text = '' - [[ -e ${config.rekey.secrets.initrd_host_ed25519_key.path} ]] \ - || ${pkgs.openssh}/bin/ssh-keygen -t ed25519 -N "" -f ${config.rekey.secrets.initrd_host_ed25519_key.path} + [[ -e ${config.age.secrets.initrd_host_ed25519_key.path} ]] \ + || ${pkgs.openssh}/bin/ssh-keygen -t ed25519 -N "" -f ${config.age.secrets.initrd_host_ed25519_key.path} ''; deps = ["agenixInstall"]; }; diff --git a/hosts/sentinel/acme.nix b/hosts/sentinel/acme.nix index 8020915..180c64c 100644 --- a/hosts/sentinel/acme.nix +++ b/hosts/sentinel/acme.nix @@ -1,8 +1,8 @@ {config, ...}: let inherit (config.repo.secrets.local) acme; in { - rekey.secrets.acme-credentials = { - file = ./secrets/acme-credentials.age; + age.secrets.acme-credentials = { + rekeyFile = ./secrets/acme-credentials.age; mode = "440"; group = "acme"; }; @@ -11,7 +11,7 @@ in { acceptTerms = true; defaults = { inherit (acme) email; - credentialsFile = config.rekey.secrets.acme-credentials.path; + credentialsFile = config.age.secrets.acme-credentials.path; dnsProvider = "cloudflare"; dnsPropagationCheck = true; reloadServices = ["nginx"]; diff --git a/hosts/sentinel/caddy.nix b/hosts/sentinel/caddy.nix index faf7307..a3a3cb1 100644 --- a/hosts/sentinel/caddy.nix +++ b/hosts/sentinel/caddy.nix @@ -15,8 +15,8 @@ in { # TODO message = "non-deterministic uid detected for: ${name}"; # TODO }); - rekey.secrets.loki-basic-auth = { - file = ./secrets/loki-basic-auth.age; + age.secrets.loki-basic-auth = { + rekeyFile = ./secrets/loki-basic-auth.age; mode = "440"; group = "caddy"; }; @@ -125,7 +125,7 @@ in { encode zstd gzip skip_log basicauth { - import ${config.rekey.secrets.loki-basic-auth.path} + import ${config.age.secrets.loki-basic-auth.path} } reverse_proxy { to http://${nodes.ward-loki.config.extra.wireguard.proxy-sentinel.ipv4}:${lokiPort} diff --git a/hosts/sentinel/secrets/loki-basic-auth.age b/hosts/sentinel/secrets/loki-basic-auth.age index 16d2be20470ec83e3d10e83dc3c2bff74b2ba5d2..50f10466068ef4865d75a23b1ed93941df0be1bf 100644 GIT binary patch delta 386 zcmV-|0e$|T1DOMmAb&zPVMAt8XEAwpL1sflHb!nnGI?=&cVRO_cu#UzYE@`RcWpIJ zaAHbnRSHjJI5cTp-Yh*Dm zVN+>1Z9y?(ZE*@@Nory+RZ3AwHZx^aY&1|tOh`mhbT@5va$!$MS!FRvFKJ0uW<_mA zHfstkJ|HnIXL4m>b7de@b8QMsW?^h(cM2^nEg*V$W^-mUcX(|}T60KhOLa+3MpG+m zSUFR9OEof3YI|^XFe_&?OgKtbV@V1dpIP%l0AlcJGTgbgNZKxcEpqPCGc_UXe}tkE&cfgS@uMfAAdehgD0$i^nbu`oNlYQRs{FIrxpuh^J+>? gb#$Sx3m&4iOlqN#yEQqU3S!i7_(2~}0Fo7jeOy|Ne*gdg delta 393 zcmV;40e1eG1D^wsAb)smHDg3}NkLO}GIMBULP9WFQ%posQdDYqOHWZoMo)E6L2NK^ zc4%@{K?*lWQAkQmN?0#AD?&q8Yi&kicvUtycy>fKT5ecLLt|HMD>gVeMKo4yRSGRW zAaH4REpRe5HXwL$Q)M_&AVG6WF=}T-Y(q0pNNYhdYFKqRR%W>Qa9O)D=@NKR!$G;w8ONeY10Gbu0iE=1q5g=Q#x zt^_aB&%h;9qz9OzYX=>*^{d@>&O?>DH5IvjLtJR5DW^@WX+(gYiR#qTGcO(#ZBJTp n<4bA*X^PF}%mwttSs;;LgS&2; + exit 1 + fi + ${concatStringsSep "\n" (flatten (mapAttrsToList x self.nodes))} + ''