]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - nixops/scripts/with_env
Add environment file instead of hardcoding everything in makefiles
[perso/Immae/Config/Nix.git] / nixops / scripts / with_env
1 #!/usr/bin/env bash
2
3 if [ -z "$NIXOPS_ENV_LOADED" ]; then
4 echo "Please load the environment with direnv"
5 exit 1;
6 fi
7
8 TEMP=$(mktemp -d /tmp/XXXXXX-nixops-files)
9 chmod go-rwx $TEMP
10
11 finish() {
12 rm -rf "$TEMP"
13 nixops set-args --unset privateFiles
14 }
15
16 trap finish EXIT
17
18 # pass cannot "just" list files in a directory without showing a tree :(
19 files=$(pass ls Nixops/files | sed -e '1d' -e 's/^.* //')
20
21 for file in $files; do
22 pass show "Nixops/files/$file" > $TEMP/$file
23 done
24 nixops set-args --argstr privateFiles "$TEMP"
25
26 "$@"