From c6431760bdea2206a8da8c7d8a0ff84704027729 Mon Sep 17 00:00:00 2001 From: Sergei Poljanski Date: Tue, 17 Nov 2026 10:35:44 +0400 Subject: [PATCH] ci: wait for a running activation before switching a host 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 --- .forgejo/workflows/nixos.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.forgejo/workflows/nixos.yaml b/.forgejo/workflows/nixos.yaml index d4b3144..06bbefc 100644 --- a/.forgejo/workflows/nixos.yaml +++ b/.forgejo/workflows/nixos.yaml @@ -81,6 +81,14 @@ jobs: continue fi 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" \ --target-host "$host" --build-host "$host" --sudo done