diff options
| author | tv <tv@krebsco.de> | 2026-11-30 22:51:37 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 01:01:26 +0000 |
| commit | ec543edc705c77052221fe5bc270d4c22938658d (patch) | |
| tree | f632a453ef7397268f3775c65528cd3de7860eaa /krops.nix | |
| parent | a301e1b900f132bcec651fe3f36b182a8572b32a (diff) | |
krops.nix: add the action enstate
It delivers only the host's enstate submissions, packed as for deploy,
and the running system takes them, without populating or building.
Diffstat (limited to 'krops.nix')
| -rw-r--r-- | krops.nix | 47 |
1 files changed, 37 insertions, 10 deletions
@@ -8,6 +8,8 @@ # deploy build the system on the target and switch to it # diff build the system on the target and show what switching to it # would change +# enstate deliver only the enstate submissions, for the running system to +# take # bootimg build the boot image (spec.nix's bootimg, an attribute of the # host's nixosConfigurations entry) on a builder, and copy it to # $HOST_CACHEDIR/results/HOSTNAME.bootimg @@ -170,17 +172,16 @@ rec { pkgs.writers.writeDash "${name}-deploy-remote-${deploy-action}" (remoteBuildScript deploy-action); - mkTargetBuildAction = build-method: deploy-action: let + # Delivering the host's enstate submissions: each channel's, from the + # host's enstate.sourceLists as this host evaluates them, gets packed + # here, goes to the target's memory, and from there to enstate's incoming + # directory. + enstateSteps = let target' = lib.mkTarget target; - name' = "${name}-deploy-${build-method}-${deploy-action}"; - # The host's enstate.sourceLists, as this host evaluates them: each - # channel's submission gets packed here, goes to the target's memory, and - # once the system is built, to where it waits for the switch, whose - # check plans it, and which takes it. - submit = deploy-action == "deploy" && sourceLists != {}; pending = "/run/krops-enstate"; stateDir = "/var/lib/enstate"; - packAndCopy = lib.optionalString submit /* sh */ '' + in { + packAndCopy = /* sh */ '' submissions=$( TMPDIR=''${XDG_RUNTIME_DIR:-''${TMPDIR:-/tmp}} \ mktemp -d --tmpdir ${name}-enstate.XXXXXXXX @@ -197,13 +198,39 @@ rec { --rsync-path=${lib.escapeShellArg "mkdir -m 0700 -p ${pending} && rsync"} \ "$submissions"/ ${lib.escapeShellArg "${target'.host}:${pending}/"} ''; - forgetPending = lib.optionalString submit /* sh */ '' + forgetPending = /* sh */ '' trap 'rm -fR ${pending}' EXIT ''; - movePending = lib.optionalString submit /* sh */ '' + movePending = /* sh */ '' mkdir -p -m 0700 ${stateDir} ${stateDir}/incoming find ${pending} -mindepth 1 -maxdepth 1 -exec mv -t ${stateDir}/incoming {} + ''; + }; + + # Only the enstate submissions, which the running system takes. + enstate = + assert lib.assertMsg (sourceLists != {}) + "${name}: no enstate sources to submit"; + pkgs.writers.writeDash "${name}-enstate" /* sh */ '' + set -efu + ${enstateSteps.packAndCopy} + ${pkgs.krops.runShell (lib.mkTarget target) {} /* sh */ '' + set -efu + ${enstateSteps.forgetPending} + ${enstateSteps.movePending} + /run/current-system/sw/bin/enstate --migrate + ''} + ''; + + mkTargetBuildAction = build-method: deploy-action: let + target' = lib.mkTarget target; + name' = "${name}-deploy-${build-method}-${deploy-action}"; + # Once the system is built, the submissions go to where they wait for + # the switch, whose check plans them, and which takes them. + submit = deploy-action == "deploy" && sourceLists != {}; + packAndCopy = lib.optionalString submit enstateSteps.packAndCopy; + forgetPending = lib.optionalString submit enstateSteps.forgetPending; + movePending = lib.optionalString submit enstateSteps.movePending; # Without a switch, nothing takes what waits: take it now. takeNow = lib.optionalString submit /* sh */ '' "$system"/sw/bin/enstate --migrate |
