From 0ef8259225b982a504dacadb49f5254dd3c65709 Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Wed, 29 Jul 2026 13:45:48 +1000 Subject: [PATCH] fix(gc-hosts): source nix-daemon profile on pve1 before running gc BatchMode SSH sessions don't source /etc/profile on non-NixOS hosts, so nix-collect-garbage isn't on PATH for the wayne user. Source the nix-daemon profile script explicitly, matching the pattern in scripts/lib/nix-bootstrap.sh. Co-Authored-By: Claude Sonnet 4.6 --- scripts/gc-hosts.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/gc-hosts.sh b/scripts/gc-hosts.sh index a9ba358..3a87cd0 100755 --- a/scripts/gc-hosts.sh +++ b/scripts/gc-hosts.sh @@ -121,7 +121,7 @@ if [[ "$DRY_RUN" -eq 1 ]]; then echo " ssh ${SSH_OPTS[*]} $target 'sudo -n nix-collect-garbage -d'" echo " # fallback: ssh ... $target 'nix-collect-garbage -d'" else - echo " ssh ${SSH_OPTS[*]} $target 'nix-collect-garbage -d'" + echo " ssh ${SSH_OPTS[*]} $target '. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix-collect-garbage -d'" fi done exit 0 @@ -147,7 +147,10 @@ gc_one() { echo "ok(user)"; return fi else - if ssh "${SSH_OPTS[@]}" "$target" "nix-collect-garbage -d" \ + # Non-NixOS node: BatchMode SSH doesn't source the Nix daemon profile, so + # nix-collect-garbage won't be on PATH unless we source it explicitly. + local nix_profile='. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh 2>/dev/null || true' + if ssh "${SSH_OPTS[@]}" "$target" "$nix_profile && nix-collect-garbage -d" \ >>"$logfile" 2>>"$logfile"; then echo "ok"; return fi