diff options
| -rw-r--r-- | krops.nix | 40 |
1 files changed, 21 insertions, 19 deletions
@@ -214,17 +214,27 @@ rec { mv ${stateDir}/incoming/."$stamp-$channel" ${stateDir}/incoming/"$stamp-$channel" done ''; + # What movePending moved, removed again, with the new system's enstate. + forgetMoved = /* sh */ '' + for channel in $channels; do + "$system"/sw/bin/enstate --forget "$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 ''; - # What movePending moved, removed again, with the new system's enstate. - forgetMoved = /* sh */ '' - for channel in $channels; do - "$system"/sw/bin/enstate --forget "$stamp-$channel" - done + # Without a switch, nothing takes what waits: take it now, unless the + # system runs only after a reboot (a deploy with boot), which takes it. + takeNow = /* sh */ '' + if [ "$(readlink -f /run/current-system)" = "$(readlink -f "$system")" ]; then + "$system"/sw/bin/enstate --migrate + ${enstateSteps.showStatus ''"$system"''} + else + echo "enstate: what waits, the reboot into $system takes" >&2 + fi ''; # What needs attention, a refused submission or a required slot without # an entry, shown, failing the deploy; quiet otherwise. @@ -259,19 +269,16 @@ rec { submit = deploy-action == "deploy" && sourceLists != {}; packAndCopy = lib.optionalString submit enstateSteps.packAndCopy; movePending = lib.optionalString submit enstateSteps.movePending; + # A refused check leaves nothing waiting. + forgetMoved = lib.optionalString submit enstateSteps.forgetMoved; + showStatus = lib.optionalString submit (enstateSteps.showStatus ''"$system"''); # 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 ":"; }; - # A refused check leaves nothing waiting. - forgetMoved = lib.optionalString submit enstateSteps.forgetMoved; - showStatus = lib.optionalString submit (enstateSteps.showStatus ''"$system"''); - # Without a switch, nothing takes what waits: take it now. - takeNow = lib.optionalString submit /* sh */ '' - "$system"/sw/bin/enstate --migrate - ''; + takeNow = lib.optionalString submit enstateSteps.takeNow; in pkgs.writers.writeDash name' /* sh */ '' set -efu @@ -316,7 +323,6 @@ rec { ${builtins.getAttr switch { switch = showStatus; boot = ""; }} else ${takeNow} - ${showStatus} echo 'Configuration is already up to date' >&2 fi ''; @@ -620,13 +626,13 @@ rec { # The submissions wait for the switch, whose check plans them, and # which takes them. submit = sourceLists != {}; + showStatus = lib.optionalString submit (enstateSteps.showStatus ''"$system"''); # 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 ":"; }; - showStatus = lib.optionalString submit (enstateSteps.showStatus ''"$system"''); setAndSwitch = /* sh */ '' old_gen=$(readlink -f /nix/var/nix/profiles/system) new_gen=$(readlink -f "$system") @@ -643,11 +649,7 @@ rec { "$system"/bin/switch-to-configuration ${switch} ${builtins.getAttr switch { switch = showStatus; boot = ""; }} else - ${lib.optionalString submit /* sh */ '' - # Without a switch, nothing takes what waits: take it now. - "$system"/sw/bin/enstate --migrate - ''} - ${showStatus} + ${lib.optionalString submit enstateSteps.takeNow} echo 'Configuration is already up to date' >&2 fi ''; |
