scripts: Add nebula-regen-all-host-certs

This commit is contained in:
SebastianStork 2026-02-05 22:08:33 +01:00
parent d45f8cd297
commit 2c76d23692
Signed by: SebastianStork
SSH key fingerprint: SHA256:tRrGdjYOwgHxpSc/wTOZQZEjxcb15P0tyXRsbAfd+2Q
5 changed files with 40 additions and 4 deletions

View file

@ -0,0 +1,30 @@
{ self', pkgs, lib, ... }:
pkgs.writeShellApplication {
name = "nebula-regen-all-host-certs";
runtimeInputs = [
pkgs.bitwarden-cli
pkgs.jq
];
text = ''
hosts="$(nix eval .#nixosConfigurations --apply 'builtins.attrNames' --json | jq -r '.[]')"
if ! declare -px BW_SESSION >/dev/null 2>&1; then
BW_SESSION="$(bw unlock --raw || bw login --raw)"
export BW_SESSION
fi
ca_key="$(mktemp)"
chmod 600 "$ca_key"
trap 'rm -f "$ca_key"' EXIT
bw get notes 'nebula ca-key' > "$ca_key"
for host in $hosts; do
echo "Regenerating certificate for $host..."
${lib.getExe self'.packages.nebula-regen-host-cert} "$host" "$ca_key"
done
echo "Done!"
'';
}