diff options
| author | tv <tv@krebsco.de> | 2026-12-01 13:42:35 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 14:12:05 +0000 |
| commit | 596bc4a5ca2d5eaa1b48d75db13d34ae05ffbe67 (patch) | |
| tree | 62a48e3c8984a71c0647f12239549f382557e6ec | |
| parent | b85cbfd8014002ddc89bbc406ae86a54380cde72 (diff) | |
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.
| -rw-r--r-- | krops.nix | 32 |
1 files changed, 22 insertions, 10 deletions
@@ -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 */ '' |
