ci: wait for a running activation before switching a host
All checks were successful
nixos / nixos (push) Successful in 1m8s

nixos-rebuild activates through a transient unit with a fixed name. An
activation that started a long one-shot job waits for it; a deploy in
the meantime failed with "did you forget --ask-sudo-password?", twice
today. Wait up to 20 minutes for the earlier activation to finish.

Assisted-by: Claude:opus-5-5
This commit is contained in:
Sergei Poljanski 2026-11-17 10:35:44 +04:00
commit c6431760bd
Signed by: asxpi
GPG key ID: 4F8851660FA4121B

View file

@ -81,6 +81,14 @@ jobs:
continue continue
fi fi
echo "== $host" echo "== $host"
# nixos-rebuild runs the activation as a fixed transient unit;
# while an earlier one still runs (it waits for one-shot units
# it started), a new switch fails with a misleading sudo error
for i in $(seq 1 120); do
nix develop -c ssh "$host" 'systemctl is-active -q nixos-rebuild-switch-to-configuration.service' || break
echo "$host: an earlier activation is still running, waiting"
sleep 10
done
nix develop -c nixos-rebuild switch --flake ".#$host" \ nix develop -c nixos-rebuild switch --flake ".#$host" \
--target-host "$host" --build-host "$host" --sudo --target-host "$host" --build-host "$host" --sudo
done done