From f07c631126720f88985dadab5961c96931ed60ea Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 4 Dec 2026 16:18:16 +0000 Subject: krops: diff plans the enstate submissions --- krops.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/krops.nix b/krops.nix index fc3fb03e..3d9aa4e1 100644 --- a/krops.nix +++ b/krops.nix @@ -7,7 +7,8 @@ # ACTIONS # deploy build the system on the target and switch to it # diff build the system on the target and show what switching to it -# would change +# would change, and what its enstate would do with the +# submissions # enstate deliver only the enstate submissions, for the running system to # take # bootimg build the boot image (spec.nix's bootimg, an attribute of the @@ -244,6 +245,18 @@ rec { echo "enstate: what waits, the reboot into $system takes" >&2 fi ''; + # What the copied submissions would do under SYSTEM, without taking them, + # each channel's, failing if one would be refused. + plan = system: /* sh */ '' + refused= + for channel in $(find ${pending} -mindepth 1 -maxdepth 1 -printf '%f\n' | sort); do + ${system}/sw/bin/enstate --plan ${pending}/"$channel" \ + --schema ${system}/etc/enstate/schema.json \ + --config ${system}/etc/enstate/config.json || + refused=1 + done + test -z "$refused" + ''; # What needs attention, a refused submission or a required slot without # an entry, shown, failing the deploy; quiet otherwise. showStatus = system: /* sh */ '' @@ -282,7 +295,9 @@ rec { # Once the system is built, the submissions go to where they wait for # the switch, whose check plans them, and which takes them. submit = deploy-action == "deploy" && sourceLists != {}; - packAndCopy = lib.optionalString submit enstateSteps.packAndCopy; + # diff plans them instead, under the new system. + packAndCopy = lib.optionalString (sourceLists != {}) enstateSteps.packAndCopy; + plan = lib.optionalString (sourceLists != {}) (enstateSteps.plan ''"$system"''); movePending = lib.optionalString submit enstateSteps.movePending; # A refused check leaves nothing waiting. forgetMoved = lib.optionalString submit enstateSteps.forgetMoved; @@ -357,6 +372,7 @@ rec { ) "$nix_diff"/bin/nix-diff /run/current-system "$system" "$system"/bin/switch-to-configuration dry-activate + ${plan} ''; }} ''} @@ -681,6 +697,7 @@ rec { ${onTarget (lib.optionalString submit enstateSteps.movePending + activate)} ''; diff = /* sh */ '' + ${lib.optionalString (sourceLists != {}) enstateSteps.packAndCopy} old_drv=$(${onTarget /* sh */ '' nix-store --query --deriver "$(readlink -f /run/current-system)" ''}) @@ -693,6 +710,7 @@ rec { ${onTarget /* sh */ '' ${nix} store diff-closures /run/current-system "$system" "$system"/bin/switch-to-configuration dry-activate + ${lib.optionalString (sourceLists != {}) (enstateSteps.plan ''"$system"'')} ''} ''; }} -- cgit v1.3.1