]> Git — Sourcephile - sourcephile-nix.git/blob - servers/losurdo/deploy.sh
gitolite: update
[sourcephile-nix.git] / servers / losurdo / deploy.sh
1 #!/bin/sh
2 set -eux
3 target=${target:-root@losurdo.sourcephile.fr}
4 # Compile the derivation of the new system
5 systemDrv=$(nix-instantiate "${0%/*}".nix \
6 -A config.system.build.toplevel \
7 ${TRACE:+--show-trace} )
8 # Compile the build products of the new system
9 system=$(nix-store --realise "$systemDrv")
10 # Send the system
11 nix copy --to ssh://"$target" --substitute-on-destination "$system"
12 # Send secrets
13 pass "servers/losurdo/root/ssh/id_ed25519" |
14 ssh "$target" install -m 0400 -o root -g root /dev/stdin \
15 /root/.ssh/id_ed25519
16 # Register and switch to the new system
17 profile=/nix/var/nix/profiles/system
18 ssh "$target" nix-env --profile "$profile" --set "$system" \
19 '&&' nix-env --profile "$profile" --delete-generations +5 \
20 '&&' "$profile"/bin/switch-to-configuration "${switch:-switch}"