summaryrefslogtreecommitdiffstats
path: root/krops.nix
diff options
context:
space:
mode:
Diffstat (limited to 'krops.nix')
-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 */ ''