summaryrefslogtreecommitdiffstats
path: root/krops.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-30 18:23:58 +0000
committertv <tv@krebsco.de>2026-11-30 23:04:56 +0000
commit10f90010255643c2f48d73bc45ec6467f6afc45d (patch)
tree717f3c161f5f4ef61084bd8d53a030f6b8681437 /krops.nix
parentc4df8322bf2e55f585276c1775c0f85b274b4df3 (diff)
krops.nix: check before setting the system profile
switch-to-configuration runs the pre-switch checks only after nix-env has made the new system the profile, so a refused switch left it to be booted next time. Only before a switch: check runs the checks as for a switch, and with boot, those that skip boot would run. The switch itself then skips them (NIXOS_NO_CHECK), so they don't run twice.
Diffstat (limited to 'krops.nix')
-rw-r--r--krops.nix9
1 files changed, 9 insertions, 0 deletions
diff --git a/krops.nix b/krops.nix
index 6a8c967e..4e531132 100644
--- a/krops.nix
+++ b/krops.nix
@@ -196,6 +196,10 @@ 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
+ ''}
nix-env -p /nix/var/nix/profiles/system --set "$system"
"$system"/bin/switch-to-configuration ${switch}
else
@@ -503,8 +507,13 @@ 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
+ ''}
nix-env -p /nix/var/nix/profiles/system --set "$system"
systemd-run --pipe --wait --collect --quiet \
+ --setenv=NIXOS_NO_CHECK="''${NIXOS_NO_CHECK-}" \
"$system"/bin/switch-to-configuration ${switch}
else
echo 'Configuration is already up to date' >&2