on master help sign in
add nix to nixOS deploy script
commitbbf0a09689f55282aa2a7b02a3f417d82099be97 authorhsloan <ishaqsloan@gmail.com> dateSun 17 Dec 2017, 13:12 (9 years ago) parent881df49
1 file changed+26
deploy+26
deploynew file+26
@@ -0,0 +1,26 @@
1+#!/usr/bin/env bash
2+set -eux
3+
4+DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
5+
6+HOSTNAME="$1"
7+shift
8+CONFIG="$1"
9+shift
10+
11+# Check preconditions
12+#diff <(ls ../config) <(ls config) # We don't want to deploy if we have the wrong set of config files
13+
14+eval "$(ssh-agent)"
15+ssh-add "$CONFIG/ssh_key"
16+
17+RESULT="$(nix-build --no-out-link -A completeServer.aws.system --argstr hostName "$HOSTNAME" "$@")"
18+
19+nix-copy-closure -v --to root@"$HOSTNAME" --gzip "$RESULT"
20+
21+"$DIR/deploy-config" "ssh" root@"$HOSTNAME" "$CONFIG"
22+
23+ssh root@"$HOSTNAME" bash -x <<EOF
24+nix-env -p /nix/var/nix/profiles/system --set "$RESULT"
25+/nix/var/nix/profiles/system/bin/switch-to-configuration switch
26+EOF