From cb04a50023e6896831f81e9640474d14d7580160 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 1 Dec 2026 13:43:24 +0000 Subject: krops.nix: forget the submissions a refused check leaves They would wait in enstate's incoming directory, and refuse every later switch to a generation that refuses them, too. --- krops.nix | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/krops.nix b/krops.nix index 3f80f5ba..83e2530c 100644 --- a/krops.nix +++ b/krops.nix @@ -208,8 +208,8 @@ rec { movePending = /* sh */ '' mkdir -p -m 0700 ${stateDir} ${stateDir}/incoming stamp=$(date -u +%Y%m%dT%H%M%SZ)-$$ - find ${pending} -mindepth 1 -maxdepth 1 -printf '%f\n' | - while read -r channel; do + channels=$(find ${pending} -mindepth 1 -maxdepth 1 -printf '%f\n') + for channel in $channels; do cp -a ${pending}/"$channel" ${stateDir}/incoming/."$stamp-$channel" mv ${stateDir}/incoming/."$stamp-$channel" ${stateDir}/incoming/"$stamp-$channel" done @@ -220,6 +220,12 @@ rec { --schema "$system"/etc/enstate/schema.json \ --config "$system"/etc/enstate/config.json ''; + # What movePending moved, removed again, with the new system's enstate. + forgetMoved = /* sh */ '' + for channel in $channels; do + "$system"/sw/bin/enstate --forget "$stamp-$channel" + done + ''; }; # Only the enstate submissions, which the running system takes. @@ -250,6 +256,8 @@ rec { switch = ''"$system"/bin/switch-to-configuration check''; boot = if submit then enstateSteps.check else ":"; }; + # A refused check leaves nothing waiting. + forgetMoved = lib.optionalString submit enstateSteps.forgetMoved; # Without a switch, nothing takes what waits: take it now. takeNow = lib.optionalString submit /* sh */ '' "$system"/sw/bin/enstate --migrate @@ -287,7 +295,12 @@ rec { old_gen=$(readlink -f /nix/var/nix/profiles/system) new_gen=$(readlink -f "$system") if [ "x$old_gen" != "x$new_gen" ]; then - ${preCheck} + if ! ( + ${preCheck} + ); then + ${forgetMoved} + exit 1 + fi nix-env -p /nix/var/nix/profiles/system --set "$system" NIXOS_NO_CHECK=1 "$system"/bin/switch-to-configuration ${switch} else @@ -605,7 +618,12 @@ rec { old_gen=$(readlink -f /nix/var/nix/profiles/system) new_gen=$(readlink -f "$system") if [ "x$old_gen" != "x$new_gen" ]; then - ${preCheck} + if ! ( + ${preCheck} + ); then + ${lib.optionalString submit enstateSteps.forgetMoved} + exit 1 + fi nix-env -p /nix/var/nix/profiles/system --set "$system" systemd-run --pipe --wait --collect --quiet \ --setenv=NIXOS_NO_CHECK=1 \ -- cgit v1.3.1