internal scripts: use pinned, cached pkgs
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
2022-08-22 12:57:39 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-11-08 11:41:42 +00:00
|
|
|
set -euo pipefail
|
internal scripts: use pinned, cached pkgs
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
2022-08-22 12:57:39 +00:00
|
|
|
. "${BASH_SOURCE[0]%/*}/../../helper/run-in-nix-env" "gnupg wget gnused" "$@"
|
2021-11-08 11:41:42 +00:00
|
|
|
|
2023-10-08 18:19:27 +00:00
|
|
|
version="0.14.1"
|
2021-12-14 18:51:19 +00:00
|
|
|
repo=https://github.com/Ride-The-Lightning/RTL
|
|
|
|
|
2022-08-21 12:41:37 +00:00
|
|
|
scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd)
|
|
|
|
|
|
|
|
updateSrc() {
|
2022-08-16 19:00:00 +00:00
|
|
|
TMPDIR=$(mktemp -d /tmp/rtl.XXX)
|
|
|
|
trap 'rm -rf $TMPDIR' EXIT
|
2021-12-14 18:51:19 +00:00
|
|
|
|
2022-08-21 12:41:37 +00:00
|
|
|
# Fetch and verify source tarball
|
|
|
|
export GNUPGHOME=$TMPDIR
|
2022-08-16 19:00:00 +00:00
|
|
|
|
2022-08-21 12:41:37 +00:00
|
|
|
# Fetch saubyk's key
|
|
|
|
gpg --keyserver hkps://keyserver.ubuntu.com --recv-key 3E9BD4436C288039CA827A9200C9E2BC2E45666F
|
2022-08-16 19:00:00 +00:00
|
|
|
file=v$version.tar.gz
|
|
|
|
wget -P "$TMPDIR" "$repo/archive/refs/tags/$file"
|
|
|
|
wget -P "$TMPDIR" "$repo/releases/download/v$version/$file.asc"
|
|
|
|
gpg --verify "$TMPDIR/$file.asc" "$TMPDIR/$file"
|
|
|
|
hash=$(nix hash file "$TMPDIR/$file")
|
2021-11-08 11:41:42 +00:00
|
|
|
|
2022-08-21 12:41:37 +00:00
|
|
|
sed -i "
|
|
|
|
s|\bversion = .*;|version = \"$version\";|
|
|
|
|
s|\bhash = .*;|hash = \"$hash\";|
|
|
|
|
" default.nix
|
|
|
|
}
|
2021-11-08 11:41:42 +00:00
|
|
|
|
2022-08-21 12:41:37 +00:00
|
|
|
updateNodeModulesHash() {
|
2022-08-16 19:00:00 +00:00
|
|
|
"$scriptDir/../../helper/update-fixed-output-derivation.sh" ./default.nix rtl.nodeModules nodeModules
|
2022-08-21 12:41:37 +00:00
|
|
|
}
|
2021-11-08 11:41:42 +00:00
|
|
|
|
2022-08-21 12:41:37 +00:00
|
|
|
if [[ $# == 0 ]]; then
|
|
|
|
# Each of these can be run separately
|
|
|
|
updateSrc
|
|
|
|
updateNodeModulesHash
|
|
|
|
else
|
2022-08-16 19:00:00 +00:00
|
|
|
"$@"
|
2022-08-21 12:41:37 +00:00
|
|
|
fi
|