]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - nixops/scripts/with_env
Simplify management of secrets in nixops
[perso/Immae/Config/Nix.git] / nixops / scripts / with_env
CommitLineData
2caad890 1#!/usr/bin/env bash
5f5efa6f 2
4506dbe5
IB
3if [ -z "$NIXOPS" ]; then
4 echo "Please set NIXOPS to the nixops command"
5 exit 1;
6fi
7
9690acd9 8TEMP=$(mktemp -d /tmp/XXXXXX-nixops-files)
5f5efa6f
IB
9chmod go-rwx $TEMP
10
11finish() {
9690acd9 12 rm -rf "$TEMP"
4506dbe5 13 $NIXOPS set-args --unset privateFiles
5f5efa6f
IB
14}
15
16trap finish EXIT
17
9690acd9 18# pass cannot "just" list files in a directory without showing a tree :(
1052bfda 19files=$(pass ls Nixops/files | sed -e '1d' -e 's/^.* //')
9690acd9
IB
20
21for file in $files; do
1052bfda 22 pass show "Nixops/files/$file" > $TEMP/$file
9690acd9 23done
4506dbe5 24$NIXOPS set-args --argstr privateFiles "$TEMP"
5f5efa6f 25
4506dbe5 26"$@"