]> Git — Sourcephile - sourcephile-nix.git/blob - servers/losurdo/deploy.sh
nix: replace nixops by shell scripts
[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 system=$(nix-instantiate "${0%/*}".nix -A config.system.build.toplevel)
6 # Compile the build products of the new system
7 nix-store --realise "$system"
8 # Send the system
9 nix-copy-closure --to "$target" --use-substitutes --gzip "$system"
10 # Register the new system
11 profile=/nix/var/nix/profiles/system
12 ssh "$target" nix-env --profile "$profile" --set "$system" \
13 '&&' nix-env --profile "$profile" --delete-generations +5
14 # Send secrets
15 pass "servers/losurdo/root/ssh/id_ed25519" |
16 ssh "$target" install -m 0400 -o root -g root /dev/stdin \
17 /root/.ssh/id_ed25519
18 # Switch to the new system
19 ssh "$target" "$profile"/bin/switch-to-configuration switch