X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=nixops%2Fscripts%2Fwith_env;h=f8e5537b43423b3ac0362d79bb8b9226f502d3ac;hb=ce95026934c4ea8c647365f68eb195459fcdff08;hp=dd0fecba878f2965e4139ee27dab33c98311f778;hpb=2caad8900d036e6a7dbd52bac2f10fd0dd4c6c79;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/nixops/scripts/with_env b/nixops/scripts/with_env index dd0fecb..f8e5537 100755 --- a/nixops/scripts/with_env +++ b/nixops/scripts/with_env @@ -1,31 +1,28 @@ #!/usr/bin/env bash -if [ -z "$NIXOPS" ]; then - echo "Please set NIXOPS to the nixops command" - exit 1; -fi - -if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then - echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_PATH to the password-store subtree path" +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" - $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/^.* //') +files=$(pass ls Nixops/files | sed -e '1d' -e 's/^.* //') for file in $files; do - pass show "$NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/files/$file" > $TEMP/$file + pass show "Nixops/files/$file" > $TEMP/$file done -$NIXOPS set-args --argstr privateFiles "$TEMP" + +export NIX_PATH="privateFiles=$TEMP:$NIX_PATH" +export SSH_IDENTITY_FILE="$TEMP/id_ed25519" "$@"