aboutsummaryrefslogtreecommitdiff
path: root/nixops/scripts/nixops_wrap
blob: d6b66bdb3f98363b0e80d6a5aee0fa0091602344 (plain) (blame)
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
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash

DeploymentUuid="cef694f3-081d-11e9-b31f-0242ec186adf"
if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then
  echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_PATH to the password-store subtree path"
  exit 1;
fi

TEMP=$(mktemp -d /tmp/XXXXXX-nixops-files)
chmod go-rwx $TEMP

finish() {
  rm -rf "$TEMP"
  nixops set-args --unset privateFiles
}

trap finish EXIT

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops"
export NIXOPS_DEPLOYMENT="$DeploymentUuid"

# pass cannot "just" list files in a directory without showing a tree :(
files=$(pass ls $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/files | sed -e '1d' -e 's/^.* //')

for file in $files; do
  pass show "$NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/files/$file" > $TEMP/$file
done
nixops set-args --argstr privateFiles "$TEMP"

# This will automatically upgrade to latest version at each build
# nixpkgsNext="https://nixos.org/channels/nixos-19.03/nixexprs.tar.xz"
nixpkgsNext="https://releases.nixos.org/nixos/19.03/nixos-19.03beta171840.23fd1394dc6/nixexprs.tar.xz"
nixpkgsPrevious="https://releases.nixos.org/nixos/18.09/nixos-18.09.1834.9d608a6f592/nixexprs.tar.xz"
nixpkgs="$nixpkgsNext"
export NIX_PATH="ssh-config-file=$(dirname $DIR)/ssh/config:nixpkgs=$nixpkgs:nixpkgsNext=$nixpkgsNext:nixpkgsPrevious=$nixpkgsPrevious"
nixops "$@"