-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·26 lines (19 loc) · 881 Bytes
/
deploy.sh
File metadata and controls
executable file
·26 lines (19 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /usr/bin/env bash
# This script builds the new system, uploads it and activates it on the target
# system. This is similar to the following blog post:
# https://vaibhavsagar.com/blog/2019/08/22/industrial-strength-deployments/.
set -euo pipefail
TARGET="root@165.22.200.188"
echo Building toplevel...
GIT_DESCRIBE=$(git describe --dirty --long)
PROFILE_PATH="$(nix-build --no-out-link -A toplevel \
--argstr nix-notes-version $GIT_DESCRIBE)"
echo $PROFILE_PATH
echo Copying toplevel closure to target system...
nix-copy-closure --to --use-substitutes $TARGET $PROFILE_PATH
echo Copying secrets to target system...
scp secrets/ssmtp-authpass $TARGET:/run/keys/ssmtp-authpass
echo Activating copied toplevel...
ssh $TARGET -- \
"nix-env --profile /nix/var/nix/profiles/system --set $PROFILE_PATH && \
/nix/var/nix/profiles/system/bin/switch-to-configuration switch"