From 6d87063f73f4da227cf49911fc1748e8c1da8661 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 1 Dec 2026 13:44:48 +0000 Subject: krops.nix: show what enstate says needs attention After the switch, or the migration without one: a submission the running generation refused (at boot, say), or a required slot without an entry, fails the deploy, with enstate --status' report. Not for boot, whose generation doesn't run yet. --- krops.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/krops.nix b/krops.nix index 83e2530c..05070d3a 100644 --- a/krops.nix +++ b/krops.nix @@ -226,6 +226,14 @@ rec { "$system"/sw/bin/enstate --forget "$stamp-$channel" done ''; + # What needs attention, a refused submission or a required slot without + # an entry, shown, failing the deploy; quiet otherwise. + showStatus = system: /* sh */ '' + if ! status=$(${system}/sw/bin/enstate --status); then + printf '%s\n' "$status" + exit 1 + fi + ''; }; # Only the enstate submissions, which the running system takes. @@ -239,6 +247,7 @@ rec { set -efu ${enstateSteps.movePending} /run/current-system/sw/bin/enstate --migrate + ${enstateSteps.showStatus "/run/current-system"} ''} ''; @@ -258,6 +267,7 @@ rec { }; # A refused check leaves nothing waiting. forgetMoved = lib.optionalString submit enstateSteps.forgetMoved; + showStatus = lib.optionalString submit (enstateSteps.showStatus ''"$system"''); # Without a switch, nothing takes what waits: take it now. takeNow = lib.optionalString submit /* sh */ '' "$system"/sw/bin/enstate --migrate @@ -303,8 +313,10 @@ rec { fi nix-env -p /nix/var/nix/profiles/system --set "$system" NIXOS_NO_CHECK=1 "$system"/bin/switch-to-configuration ${switch} + ${builtins.getAttr switch { switch = showStatus; boot = ""; }} else ${takeNow} + ${showStatus} echo 'Configuration is already up to date' >&2 fi ''; @@ -614,6 +626,7 @@ rec { switch = ''"$system"/bin/switch-to-configuration check''; boot = if submit then enstateSteps.check else ":"; }; + showStatus = lib.optionalString submit (enstateSteps.showStatus ''"$system"''); setAndSwitch = /* sh */ '' old_gen=$(readlink -f /nix/var/nix/profiles/system) new_gen=$(readlink -f "$system") @@ -628,11 +641,13 @@ rec { systemd-run --pipe --wait --collect --quiet \ --setenv=NIXOS_NO_CHECK=1 \ "$system"/bin/switch-to-configuration ${switch} + ${builtins.getAttr switch { switch = showStatus; boot = ""; }} else ${lib.optionalString submit /* sh */ '' # Without a switch, nothing takes what waits: take it now. "$system"/sw/bin/enstate --migrate ''} + ${showStatus} echo 'Configuration is already up to date' >&2 fi ''; -- cgit v1.3.1