aboutsummaryrefslogtreecommitdiff
path: root/nixops/scripts/with_env
blob: 9882f787f120c855a8b291bdf534d24356c143b1 (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
#!/usr/bin/env bash

if [ -z "$NIXOPS_ENV_LOADED" ]; then
  echo "Please load the environment with direnv"
  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

# 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
nixops set-args --argstr privateFiles "$TEMP"

"$@"