summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-01 13:42:35 +0000
committertv <tv@krebsco.de>2026-12-01 14:12:05 +0000
commitcc4e05d924b9167244550448ff07bab850415069 (patch)
tree2b3833cc0f0991335c624cfb0c14155e44b1f7e1
parentf35d0656232bde7beb09d1575a60d8ab8aea72fb (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.nix32
1 files changed, 22 insertions, 10 deletions
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] Unable to lock slot /tmp/cgit/cf000000.lock: Permission denied (13)