summaryrefslogtreecommitdiffstats
path: root/krops.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-01 13:43:24 +0000
committertv <tv@krebsco.de>2026-12-01 14:12:09 +0000
commitcb04a50023e6896831f81e9640474d14d7580160 (patch)
tree81e5c5ac7148ac08cd5f95494533c0fe7addc4bf /krops.nix
parent596bc4a5ca2d5eaa1b48d75db13d34ae05ffbe67 (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.nix26
1 files 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 \