aboutsummaryrefslogblamecommitdiff
path: root/nixops/scripts/with_env
blob: f8e5537b43423b3ac0362d79bb8b9226f502d3ac (plain) (tree)
1
2
3
4
5
6
7
8
9
                   
 

                                                


         
          
                                          


                  
                



                
                                                                        
                                                         

                      
                                              
    


                                              
 
    
#!/usr/bin/env bash

if [ -z "$NIXOPS_ENV_LOADED" ]; then
  echo "Please load the environment with direnv"
  exit 1;
fi

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

finish() {
  rm -rf "$TEMP"
}

trap finish EXIT

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

for file in $files; do
  pass show "Nixops/files/$file" > $TEMP/$file
done

export NIX_PATH="privateFiles=$TEMP:$NIX_PATH"
export SSH_IDENTITY_FILE="$TEMP/id_ed25519"

"$@"