aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2026-01-02 17:42:31 +0000
committerDavid Morgan <djm_uk@protonmail.com>2026-01-02 17:42:31 +0000
commitefbfacba16bf233b886ad3f0e50b4b62bc3a3a11 (patch)
treeedf3451987ba9670ab81afbba61143ed22f831b6
parentb1eef3548b55a5e7d334a05909cacaa4a5d3cc80 (diff)
downloaddotfiles-efbfacba16bf233b886ad3f0e50b4b62bc3a3a11.tar.gz
Migrate edrahil weak secrets to private.nix.age
-rw-r--r--nix-conf/hosts/nixos/edrahil/private.nix.agebin0 -> 572 bytes
-rw-r--r--nix-conf/hosts/nixos/edrahil/secrets.yaml11
-rw-r--r--nix-conf/hosts/nixos/modules/host-secrets/default.nix30
-rw-r--r--nix-conf/nix-plugins/extra-builtins.nix6
4 files changed, 29 insertions, 18 deletions
diff --git a/nix-conf/hosts/nixos/edrahil/private.nix.age b/nix-conf/hosts/nixos/edrahil/private.nix.age
new file mode 100644
index 0000000..78df026
--- /dev/null
+++ b/nix-conf/hosts/nixos/edrahil/private.nix.age
Binary files differ
diff --git a/nix-conf/hosts/nixos/edrahil/secrets.yaml b/nix-conf/hosts/nixos/edrahil/secrets.yaml
index f86c098..2d25e20 100644
--- a/nix-conf/hosts/nixos/edrahil/secrets.yaml
+++ b/nix-conf/hosts/nixos/edrahil/secrets.yaml
@@ -1,10 +1,3 @@
-networking:
- interfaces:
- ens3:
- ipv6:
- addresses:
- - address: ENC[AES256_GCM,data:3FuCZgowlSL+/BJN7/gaZ9p3mvw=,iv:Ew1TKJHwYoKbnkYfgLv4V5PyQ+JtZpGe85U6idxEtJ8=,tag:VUl7IZ0XnKt45BdUbpOx1w==,type:str]
- prefixLength: ENC[AES256_GCM,data:CEw=,iv:Qa0cdfD97H4/UPw/lRg0fGhm0RTC+7Z16Tgu891d9GI=,tag:HoPrzRHzl+8utAeEROVyCw==,type:int]
restic:
password: ENC[AES256_GCM,data:ehazeFMRhmMTF8HvNaVaeQ4BsDvbgg==,iv:T70u2KggtaLIBE/G6wAQhJye8MwIFkxhRisEGQbl/NM=,tag:ykucuPFc0DCpxwGE0UAquA==,type:str]
sops:
@@ -27,7 +20,7 @@ sops:
Qm1PWnAvZGcxWGZjcnE4QWJZaDE2cGMKOAfTIipI68eJnOnvpQyLCOyH1KAWd/d/
SLnJQ+rmh9onA/znahB7Pn3LQtfKLNBADVtwLIuPID0FcgUW7nlOiw==
-----END AGE ENCRYPTED FILE-----
- lastmodified: "2025-12-26T13:13:13Z"
- mac: ENC[AES256_GCM,data:SFsNDNGd5SbXROzkRArwxFJRRlxkXCrGM8TxNZ1hbrEaCPYN7X+KMSRq6YkkkOw44q68S681nE+V3fAJ0r+iY5dr93s8t8loFujX8hyGsLa6Kt6FpNAkON2aDin34uu3UWjR2qBeeAxgpHV1MJEVKpOlfpEIXXk1yOJsuxQAbAc=,iv:Q9Knc+Rn+tbplcXxydFM/8ATFYpxeVV3LZ7JKCq8rxU=,tag:LOcplrEcrUUt3Di9VLNcEw==,type:str]
+ lastmodified: "2026-01-02T17:39:30Z"
+ mac: ENC[AES256_GCM,data:Jxs3C+EPMv62u0ywxhfGfKSj+InobUF7nJC3Yf12Bz3M61X/l4KfYh0cdBoNhgcAkEAmK5fAGK77bU7i1MVCVyIiTTgxysvTg+hit5rqyR1g2cyRaSYDuK0VGTmI22dkPfmAIGrL1+v6t7AZj+yi/wcKW1mvefGGR10GBfBfmdU=,iv:19DsfPlUFbmyaG/ojir9yk1x8/AHYP+wm8+j2m844JM=,tag:acDlHqWGgejtXPoEEAzDfQ==,type:str]
unencrypted_suffix: _unencrypted
version: 3.11.0
diff --git a/nix-conf/hosts/nixos/modules/host-secrets/default.nix b/nix-conf/hosts/nixos/modules/host-secrets/default.nix
index 3075aea..dcf0d9f 100644
--- a/nix-conf/hosts/nixos/modules/host-secrets/default.nix
+++ b/nix-conf/hosts/nixos/modules/host-secrets/default.nix
@@ -7,6 +7,7 @@
}:
let
sopsFile = ../../. + "/${config.networking.hostName}/secrets.yaml";
+ ageFile = ../../. + "/${config.networking.hostName}/private.nix.age";
in
{
imports = [
@@ -17,15 +18,26 @@ in
# addresses that are not really secrets, but are better kept
# private
host.private =
- if builtins.extraBuiltins == null then
- throw "extraBuiltins is not available"
- else if !(builtins.extraBuiltins ? readSopsForHost) then
- throw "extraBuiltins.readSopsForHost is not available"
- else if !builtins.pathExists sopsFile then
- throw "secrets.yaml does not exist for ${config.networking.hostName}"
- else
- builtins.extraBuiltins.readSopsForHost sopsFile;
-
+ (
+ if builtins.extraBuiltins == null then
+ throw "extraBuiltins is not available"
+ else if !(builtins.extraBuiltins ? readSopsForHost) then
+ throw "extraBuiltins.readSopsForHost is not available"
+ else if !builtins.pathExists sopsFile then
+ throw "secrets.yaml does not exist for ${config.networking.hostName}"
+ else
+ builtins.extraBuiltins.readSopsForHost sopsFile
+ )
+ // (
+ if builtins.extraBuiltins == null then
+ throw "extraBuiltins is not available"
+ else if !(builtins.extraBuiltins ? readRageForHost) then
+ throw "extraBuiltins.readRageForHost is not available"
+ else if !builtins.pathExists ageFile then
+ throw "private.nix.age does not exist for ${config.networking.hostName}"
+ else
+ builtins.extraBuiltins.readRageForHost ageFile
+ );
environment.systemPackages = with pkgs; [
sops
diff --git a/nix-conf/nix-plugins/extra-builtins.nix b/nix-conf/nix-plugins/extra-builtins.nix
index 2c64a7e..7236a9b 100644
--- a/nix-conf/nix-plugins/extra-builtins.nix
+++ b/nix-conf/nix-plugins/extra-builtins.nix
@@ -8,4 +8,10 @@
readSopsForHost = secretsFile: exec [ "sh" "-c"
("nix eval --expr \"builtins.fromJSON(''\$(SOPS_AGE_KEY=`doas ssh-to-age -private-key -i /etc/ssh/ssh_host_ed25519_key` sops --output-type json -d '" + secretsFile + "')'')\"")
];
+
+ readRageForHost = nixAgeFile:
+ exec [ "doas" "rage" "-d" "-i" "/etc/ssh/ssh_host_ed25519_key" nixAgeFile ];
+
+ readRageForKey = keyFile: nixAgeFile:
+ exec [ "rage" "-d" "-i" keyFile nixAgeFile ];
}