diff options
| -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 \ |
