From a301e1b900f132bcec651fe3f36b182a8572b32a Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 30 Nov 2026 21:05:24 +0000 Subject: 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. --- configs/retiolum.nix | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'configs') 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" ]; -- cgit v1.3.1