mirror of
https://github.com/fort-nix/nix-bitcoin.git
synced 2024-11-23 14:56:43 +03:00
af115d746b
Instead of setting up the script PATH via nix-shell, use `nix shell` with inputs from the nix-bitcoin flake. Advantages: - Uses the nixpkgs version from the nix-bitcoin flake instead of `<nixpkgs>` from the user env (NIX_PATH), so the script runtime env is reproducible. - The pkg derivations for the runtime env are cached, which greatly increases script startup speed. This commit was generated by running the following script inside the repo root dir: def transform(path, src) if src =~ /#! *nix-shell +-i +bash +-p +(.*)/ pkgs = $1 if src =~ /^.*?(set -e.*?pipefail)\n/ set_statement = $1 src.sub!($&, '') end src.sub!(/\A.*?#! *nix-shell.*?\n/m, '') parents = ([ '..' ] * (path.split('/').count - 1)).join('/') [ '#!/usr/bin/env bash', *set_statement, %(. "${BASH_SOURCE[0]%/*}/#{parents}/helper/run-in-nix-env" "#{pkgs}" "$@"), nil, src ].join("\n") end end Dir['**/*.sh'].each do |f| src = File.read(f) if new_src = transform(f, src) puts "Changed file #{f}" File.write(f, new_src) end end
27 lines
799 B
Bash
Executable File
27 lines
799 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
. "${BASH_SOURCE[0]%/*}/../../helper/run-in-nix-env" "git gnupg curl jq" "$@"
|
|
|
|
TMPDIR=$(mktemp -d -p /tmp)
|
|
trap 'rm -rf $TMPDIR' EXIT
|
|
cd "$TMPDIR"
|
|
|
|
echo "Fetching latest release"
|
|
repo=lightninglabs/lndinit
|
|
latest=$(curl -fsS "https://api.github.com/repos/$repo/releases/latest" | jq -r .tag_name)
|
|
echo "Latest release is $latest"
|
|
git clone --depth 1 --branch "$latest" https://github.com/lightninglabs/lndinit 2>/dev/null
|
|
cd lndinit
|
|
|
|
# GPG verification
|
|
export GNUPGHOME=$TMPDIR
|
|
echo "Fetching Oliver Gugger's key"
|
|
gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys F4FC70F07310028424EFC20A8E4256593F177720 2> /dev/null
|
|
echo "Verifying latest release"
|
|
git verify-tag "$latest"
|
|
|
|
echo "tag: $latest"
|
|
git checkout -q "tags/$latest"
|
|
rm -rf .git
|
|
nix hash path .
|