From 596bc4a5ca2d5eaa1b48d75db13d34ae05ffbe67 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 1 Dec 2026 13:42:35 +0000 Subject: krops.nix: check before boot, too enstate's check runs for boot now (enstate 34ac5db), and runs before the profile is set only by the separate check. For boot, that's enstate's check alone, run as its module runs it: NixOS' check of switch inhibitors skips boot, but not when switch-to-configuration runs it as check, and would refuse a deploy with boot for what boot is for. --- krops.nix | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'krops.nix') diff --git a/krops.nix b/krops.nix index 5468f6ab..3f80f5ba 100644 --- a/krops.nix +++ b/krops.nix @@ -214,6 +214,12 @@ rec { mv ${stateDir}/incoming/."$stamp-$channel" ${stateDir}/incoming/"$stamp-$channel" done ''; + # enstate's check before a switch, as its module runs it, of what waits. + check = /* sh */ '' + "$system"/sw/bin/enstate --migrate --dry-run \ + --schema "$system"/etc/enstate/schema.json \ + --config "$system"/etc/enstate/config.json + ''; }; # Only the enstate submissions, which the running system takes. @@ -238,6 +244,12 @@ rec { submit = deploy-action == "deploy" && sourceLists != {}; packAndCopy = lib.optionalString submit enstateSteps.packAndCopy; movePending = lib.optionalString submit enstateSteps.movePending; + # NixOS' check of switch inhibitors skips boot, but not when run as + # check: for boot, enstate's alone. + preCheck = builtins.getAttr switch { + switch = ''"$system"/bin/switch-to-configuration check''; + boot = if submit then enstateSteps.check else ":"; + }; # Without a switch, nothing takes what waits: take it now. takeNow = lib.optionalString submit /* sh */ '' "$system"/sw/bin/enstate --migrate @@ -275,12 +287,9 @@ rec { old_gen=$(readlink -f /nix/var/nix/profiles/system) new_gen=$(readlink -f "$system") if [ "x$old_gen" != "x$new_gen" ]; then - ${lib.optionalString (switch == "switch") /* sh */ '' - "$system"/bin/switch-to-configuration check - export NIXOS_NO_CHECK=1 - ''} + ${preCheck} nix-env -p /nix/var/nix/profiles/system --set "$system" - "$system"/bin/switch-to-configuration ${switch} + NIXOS_NO_CHECK=1 "$system"/bin/switch-to-configuration ${switch} else ${takeNow} echo 'Configuration is already up to date' >&2 @@ -586,17 +595,20 @@ rec { # The submissions wait for the switch, whose check plans them, and # which takes them. submit = sourceLists != {}; + # NixOS' check of switch inhibitors skips boot, but not when run as + # check: for boot, enstate's alone. + preCheck = builtins.getAttr switch { + switch = ''"$system"/bin/switch-to-configuration check''; + boot = if submit then enstateSteps.check else ":"; + }; setAndSwitch = /* sh */ '' old_gen=$(readlink -f /nix/var/nix/profiles/system) new_gen=$(readlink -f "$system") if [ "x$old_gen" != "x$new_gen" ]; then - ${lib.optionalString (switch == "switch") /* sh */ '' - "$system"/bin/switch-to-configuration check - export NIXOS_NO_CHECK=1 - ''} + ${preCheck} nix-env -p /nix/var/nix/profiles/system --set "$system" systemd-run --pipe --wait --collect --quiet \ - --setenv=NIXOS_NO_CHECK="''${NIXOS_NO_CHECK-}" \ + --setenv=NIXOS_NO_CHECK=1 \ "$system"/bin/switch-to-configuration ${switch} else ${lib.optionalString submit /* sh */ '' -- cgit v1.3.1