aboutsummaryrefslogblamecommitdiff
path: root/nixops/scripts/nixops_wrap
blob: d03784e78c3fa575217f6d37a795aca0be72d171 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

           
                                                     

                                                                                      

         



                                                                       
                                                                                  
 
                                          

                  


                                                                      
 
          
                
                                       



                





                                                                                          
                                              
 
            
#!/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
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops"
export NIXOPS_DEPLOYMENT="$DeploymentUuid"
source $(dirname $(dirname $DIR))/nix_path_env
nixops="$(nix-build --no-out-link "$(dirname $DIR)/custom_nixops.nix")/bin/nixops"

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

# __noChroot: ssh-config-file requires relaxed
export NIX_PATH="ssh-config-file=$(dirname $DIR)/ssh/config:$NIX_PATH"


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

trap finish EXIT

# 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"

$nixops "$@"