From 419f17be2d0e828f571655fac44c4d19f638dbac Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Mon, 20 Jul 2026 16:36:14 +1000 Subject: [PATCH] Fix create-proxmox-resource.sh --dry-run hiding nix-cache probe results The tarball/disko-image build previews were hardcoded strings that never included ${NIX_OPTS[@]}, so --dry-run always showed the same "would build" command whether nix-cache's substituter/remote-builder got disabled by nix_extra_opts's reachability probe or not -- the actual (non-dry-run) build commands already applied it correctly, only the preview lied. Co-Authored-By: Claude Sonnet 5 --- scripts/create-proxmox-resource.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/create-proxmox-resource.sh b/scripts/create-proxmox-resource.sh index ed4f8d4..5d6ce11 100755 --- a/scripts/create-proxmox-resource.sh +++ b/scripts/create-proxmox-resource.sh @@ -393,9 +393,19 @@ else fi if [[ "$image_already_remote" -eq 0 && -z "$local_image" ]]; then + # Mirrors the real build commands' "${NIX_OPTS[@]}" below -- nix_extra_opts + # (called earlier, once) has already decided whether nix-cache is in play, + # and the dry-run preview needs to reflect that decision instead of always + # printing the same command regardless of outcome. + nix_opts_display="" + if [[ ${#NIX_OPTS[@]} -gt 0 ]]; then + printf -v nix_opts_display '%q ' "${NIX_OPTS[@]}" + nix_opts_display=" ${nix_opts_display% }" + fi if [[ "$type" == "lxc" ]]; then if [[ "$dry_run" -eq 1 ]]; then echo "[dry-run] would build: NIXOS_HOST_KEYS_DIR=${repo_root}/host-keys nix build --impure \\" + echo "[dry-run] --no-use-registries --no-accept-flake-config${nix_opts_display} \\" echo "[dry-run] .#nixosConfigurations.${flake_target}.config.system.build.tarball" local_image="" else @@ -409,7 +419,8 @@ if [[ "$image_already_remote" -eq 0 && -z "$local_image" ]]; then fi else if [[ "$dry_run" -eq 1 ]]; then - echo "[dry-run] would build: nix build .#nixosConfigurations.${flake_target}.config.system.build.diskoImagesScript" + echo "[dry-run] would build: nix build --no-use-registries --no-accept-flake-config${nix_opts_display} \\" + echo "[dry-run] .#nixosConfigurations.${flake_target}.config.system.build.diskoImagesScript" echo "[dry-run] would run: sudo ./result-${flake_target} \\" echo "[dry-run] --pre-format-files host-keys/${flake_target}_ssh_host_ed25519_key /etc/ssh/ssh_host_ed25519_key \\" echo "[dry-run] --pre-format-files host-keys/${flake_target}_ssh_host_ed25519_key.pub /etc/ssh/ssh_host_ed25519_key.pub \\" -- 2.54.0