diff options
| author | tv <tv@krebsco.de> | 2026-11-30 21:05:24 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 01:01:26 +0000 |
| commit | a301e1b900f132bcec651fe3f36b182a8572b32a (patch) | |
| tree | 0a8c1323b5134f26aa6b27e2cb59305910e16d24 | |
| parent | 0b9a35c301558f675ca825b2e9a3619471243d45 (diff) | |
ru: take retiolum's key from enstate
configs/retiolum.nix takes it from enstate wherever enstate is enabled,
as application/x-tinc-private-key; algorithm=ed25519, a type of hrm's
own, with a validator, and names its source: the host's entry in the
passage store, unless the host names another.
| -rw-r--r-- | configs/retiolum.nix | 37 | ||||
| -rw-r--r-- | systems/ru/config.nix | 2 |
2 files changed, 38 insertions, 1 deletions
diff --git a/configs/retiolum.nix b/configs/retiolum.nix index 143d2ca2..998cbccb 100644 --- a/configs/retiolum.nix +++ b/configs/retiolum.nix @@ -1,6 +1,28 @@ { config, inputs, lib, mylib, pkgs, ... }: let host = config.krebs.build.host; net = host.nets.retiolum; + keyType = "application/x-tinc-private-key; algorithm=ed25519"; + keySlot = config.enstate.channels.secrets.slots."retiolum.key"; + keyValidator = pkgs.writers.writeDash "validate-tinc-ed25519-private-key" '' + set -efu + ${pkgs.jq}/bin/jq -r -f ${pkgs.writeJq "slots-of-type.jq" '' + .slots | to_entries[] | select(.value.type == $ARGS.named.type) | .key + ''} --arg type ${lib.escapeShellArg keyType} "$1"/invocation.json | + while read -r address; do + test -e "$1"/channels/"$address" || continue + ${pkgs.jq}/bin/jq -Rsc -f ${pkgs.writeJq "check-tinc-ed25519-private-key.jq" '' + "-----BEGIN ED25519 PRIVATE KEY-----" as $begin | + "-----END ED25519 PRIVATE KEY-----" as $end | + split("\n") | if .[-1] == "" then .[:-1] else . end | + if length == 0 then "is empty" + elif .[0] != $begin then "does not start with \($begin)" + elif .[-1] != $end then "does not end with \($end)" + elif length < 3 then "has no key between its first and last line" + else empty end | + { address: $ARGS.named.address, message: "the key \(.)" } + ''} --arg address "$address" "$1"/channels/"$address" + done + ''; in { imports = [ # The module only uses crane for its default package. @@ -16,7 +38,8 @@ in { nodeName = host.name; listenPort = net.tinc.port; ed25519PrivateKeyFile = - "${config.krebs.secret.directory}/retiolum.ed25519_key.priv"; + if config.enstate.enable then keySlot.path + else "${config.krebs.secret.directory}/retiolum.ed25519_key.priv"; hosts = lib.mapAttrs (_: host: host.nets.retiolum.tinc.config) (lib.filterAttrs @@ -43,6 +66,18 @@ in { # stall TCP. systemd.network.networks."40-tincr-retiolum".linkConfig.MTUBytes = "1377"; } + (lib.mkIf config.enstate.enable { + enstate.types.${keyType}.validator = keyValidator; + enstate.channels.secrets.slots."retiolum.key" = { + type = keyType; + secret = true; + source = lib.mkDefault { + command = [ + "secrets" host.name "retiolum.ed25519_key.priv" + ]; + }; + }; + }) (lib.mkIf (!config.hrm.nftables.enable) { tv.iptables.input-internet-accept-tcp = [ "tinc" ]; tv.iptables.input-internet-accept-udp = [ "tinc" ]; diff --git a/systems/ru/config.nix b/systems/ru/config.nix index 41447bba..b2722683 100644 --- a/systems/ru/config.nix +++ b/systems/ru/config.nix @@ -34,5 +34,7 @@ krebs.build.host = config.krebs.hosts.ru; + enstate.enable = true; + system.stateVersion = "22.11"; } |
