diff options
| author | tv <tv@krebsco.de> | 2026-12-01 13:43:24 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 14:12:09 +0000 |
| commit | cb04a50023e6896831f81e9640474d14d7580160 (patch) | |
| tree | 81e5c5ac7148ac08cd5f95494533c0fe7addc4bf /krops.nix | |
| parent | 596bc4a5ca2d5eaa1b48d75db13d34ae05ffbe67 (diff) | |
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.
Diffstat (limited to 'krops.nix')
| -rw-r--r-- | krops.nix | 26 |
1 files changed, 22 insertions, 4 deletions
@@ -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 \ |
