This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.deploy: record the deployed revision in /var/lib/superconfig-revision

The flake's git revision (-dirty with uncommitted changes, unknown for non-git sources) is copied to the target with the source and written by deploy-switch once the switch succeeded. Read by the monitoring agent; it is in no derivation, so a commit doesn't change every machine's closure.

+12 -4
+12 -4
tools/deploy/flake-module.nix
··· 14 14 # (progress via nom), shows the source diff against the running system 15 15 # (/var/lib/deploy/src) and the closure diff, asks (--yes: does not 16 16 # ask and prints the diffs without a pager), then uploads 17 - # secrets and switches in the unit deploy-switch. Both units survive 18 - # the ssh connection dying; rerunning deploy attaches to a running one. 17 + # secrets and switches in the unit deploy-switch, which records the 18 + # deployed git revision in /var/lib/superconfig-revision. Both units 19 + # survive the ssh connection dying; rerunning deploy attaches to a 20 + # running one. 19 21 packages.deploy = 20 22 (pkgs.writeShellApplication { 21 23 name = "deploy"; ··· 190 192 191 193 step "copying source to $target:$state/incoming" 192 194 # The flake source exactly as nix sees it: tracked files only. 193 - src=$(nix flake metadata --json "$flake" | jq -r .path) 195 + meta=$(nix flake metadata --json "$flake") 196 + src=$(jq -r .path <<<"$meta") 197 + # Its git revision (-dirty with uncommitted changes), written to 198 + # /var/lib/superconfig-revision once the switch succeeded. 199 + revision=$(jq -r '.revision // .dirtyRevision // "unknown"' <<<"$meta") 194 200 tar -C "$src" --owner=0 --group=0 --numeric-owner -czf - . | 195 201 remote "rm -rf $state/incoming.new && mkdir -p $state/incoming.new &&" \ 196 202 "tar -C $state/incoming.new -xzf - &&" \ 197 - "rm -rf $state/incoming && mv $state/incoming.new $state/incoming" 203 + "rm -rf $state/incoming && mv $state/incoming.new $state/incoming &&" \ 204 + "echo $revision >$state/incoming.revision" 198 205 199 206 step "source changes" 200 207 source_diff | page ··· 249 256 start deploy-switch \ 250 257 -p "ExecStartPre=/run/current-system/sw/bin/nix-env -p /nix/var/nix/profiles/system --set $system" \ 251 258 -p "ExecStartPre=/bin/sh -c 'rm -rf $state/src && cp -a $state/incoming $state/src'" \ 259 + -p "ExecStartPost=/bin/sh -c '(cat $state/incoming.revision || echo unknown) >/var/lib/superconfig-revision.tmp && mv /var/lib/superconfig-revision.tmp /var/lib/superconfig-revision'" \ 252 260 "$system/bin/switch-to-configuration" switch 253 261 follow deploy-switch 254 262 '';