]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - nixops/scripts/pull_deployment
Use systemd RuntimeDirectory and StateDirectory entries to ensure runtime directory...
[perso/Immae/Config/Nix.git] / nixops / scripts / pull_deployment
1 #!/bin/bash
2
3 DeploymentUuid="cef694f3-081d-11e9-b31f-0242ec186adf"
4 if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then
5 echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_PATH to the password-store subtree path"
6 exit 1;
7 fi
8 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
9 export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops"
10 export NIXOPS_DEPLOYMENT="$DeploymentUuid"
11 source $(dirname $(dirname $DIR))/nix_path_env
12 nixops="$(nix-build --no-out-link "$(dirname $DIR)/custom_nixops.nix")/bin/nixops"
13
14 export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops"
15
16 if $nixops info -d $DeploymentUuid 2>/dev/null >/dev/null; then
17 cat <<EOF
18 This will remove your current deployment file and recreate it!
19 Continue? [y/N]
20 EOF
21 read y
22 if [ "$y" = "y" -o "$y" = "Y" ]; then
23 $nixops delete --force -d $DeploymentUuid
24 else
25 echo "Aborting"
26 exit 1
27 fi
28 fi
29
30 deployment=$(pass show $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/Deployment)
31
32 echo "$deployment" | $nixops import
33
34 $nixops modify -d "$DeploymentUuid" "$(dirname $DIR)/eldiron.nix"