examples/deploy-container: fix sudo env propagation

Env vars can't be reliably passed through `sudo`, so always
call nix-shell to setup the env after running sudo.
This commit is contained in:
Erik Arvstedt 2023-01-03 19:36:27 +01:00
parent 8d476cfeaf
commit 4b5b4eac58
No known key found for this signature in database
GPG key ID: 33312B944DD97846
2 changed files with 11 additions and 19 deletions

View file

@ -1,17 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -v NIX_BITCOIN_EXAMPLES_DIR ]]; then
echo "Running script in nix shell env..."
cd "${BASH_SOURCE[0]%/*}"
exec nix-shell --run "./${BASH_SOURCE[0]##*/} $*"
else
cd "$NIX_BITCOIN_EXAMPLES_DIR"
fi
tmpDir=$(mktemp -d /tmp/nix-bitcoin-minimal-container.XXX)
trap 'rm -rf $tmpDir' EXIT
cd "${BASH_SOURCE[0]%/*}"
# Modify importable-configuration.nix to use the local <nix-bitcoin>
# source instead of fetchTarball
<importable-configuration.nix sed '
@ -31,4 +25,4 @@ cat > "$tmpDir/configuration.nix" <<EOF
}
EOF
"${BASH_SOURCE[0]%/*}/deploy-container.sh" "$tmpDir/configuration.nix" "$@"
./deploy-container.sh "$tmpDir/configuration.nix" "$@"