From 2fd483697b2d1037aac4c381b3d22d926dc40357 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 20 Jul 2026 09:49:31 +0000 Subject: [PATCH] Don't refuse recreating the canonical already-deployed target itself The duplicate-host check in create-proxmox-resource.sh compared by hostName only, so it fired even when the target being created was exactly the one variables.nix's deployedTargets already names (e.g. rebuilding lxc-nix-cache after destroying its old container to pick up new sops secrets) -- there's no other machine at risk of an identity collision in that case, just the normal redeploy workflow. Skip the check when dt == flake_target; the later VMID-existence check still guards against clobbering a resource that's actually live on the node. Co-Authored-By: Claude Sonnet 5 --- scripts/create-proxmox-resource.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/create-proxmox-resource.sh b/scripts/create-proxmox-resource.sh index 5d6ce11..f1e952d 100755 --- a/scripts/create-proxmox-resource.sh +++ b/scripts/create-proxmox-resource.sh @@ -289,11 +289,17 @@ fi # --- refuse to duplicate a host that's already really deployed ---------- # Checked by hostName, not exact flake target: proxmox-server being # deployed also blocks --type lxc --host server, since both would carry -# the same hosts/server/host.nix identity (hostName, hostId). +# the same hosts/server/host.nix identity (hostName, hostId). But skip the +# check when dt == flake_target -- that's not a duplicate, it's recreating +# the canonical deployed target itself (e.g. redeploying nix-cache after +# destroying its old VM/container to pick up new sops secrets), and the +# later VMID-existence check already guards against clobbering a live +# resource. if [[ "$allow_duplicate_host" -eq 0 ]]; then deployed_targets_json="$(nix eval --json --no-use-registries --no-accept-flake-config \ --file "${repo_root}/variables.nix" deployedTargets)" for dt in $(echo "$deployed_targets_json" | jq -r '.[]'); do + [[ "$dt" == "$flake_target" ]] && continue dt_hostname="$(nix eval --raw --no-use-registries --no-accept-flake-config \ "${repo_root}#nixosConfigurations.${dt}.config.networking.hostName" 2>/dev/null || true)" if [[ "$dt_hostname" == "$host" ]]; then