cl-rest: 0.7.2 -> 0.8.0

- Use `fetch-node-modules`
- Only use nodejs-slim as a runtime dependency
This commit is contained in:
Erik Arvstedt 2022-08-21 14:41:38 +02:00
parent 617ed4c8e8
commit 53dd2a1ae2
No known key found for this signature in database
GPG key ID: 33312B944DD97846
6 changed files with 75 additions and 1543 deletions

View file

@ -1,44 +1,40 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nodePackages.node2nix gnupg wget jq gnused
#! nix-shell -i bash -p gnupg wget gnused
set -euo pipefail
TMPDIR="$(mktemp -d -p /tmp)"
trap "rm -rf $TMPDIR" EXIT
version="0.7.2"
version="0.8.0"
repo=https://github.com/Ride-The-Lightning/c-lightning-REST
# Fetch and verify source tarball
file=v${version}.tar.gz
url=$repo/archive/refs/tags/$file
export GNUPGHOME=$TMPDIR
gpg --keyserver hkps://keyserver.ubuntu.com --recv-key 3E9BD4436C288039CA827A9200C9E2BC2E45666F
wget -P $TMPDIR $url
wget -P $TMPDIR $repo/releases/download/v${version}/$file.asc
gpg --verify $TMPDIR/$file.asc $TMPDIR/$file
hash=$(nix hash file $TMPDIR/$file)
scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd)
# Extract source
src=$TMPDIR/src
mkdir $src
tar xvf $TMPDIR/$file -C $src --strip-components 1 >/dev/null
updateSrc() {
TMPDIR="$(mktemp -d /tmp/clightning-rest.XXX)"
trap "rm -rf $TMPDIR" EXIT
# Generate nix pkg
node2nix \
--input $src/package.json \
--lock $src/package-lock.json \
--composition composition.nix \
--no-copy-node-env
# Fetch and verify source tarball
export GNUPGHOME=$TMPDIR
# Fetch saubyk's key
gpg --keyserver hkps://keyserver.ubuntu.com --recv-key 3E9BD4436C288039CA827A9200C9E2BC2E45666F
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)
# Use node-env.nix from nixpkgs
nodeEnvImport='import "${toString pkgs.path}/pkgs/development/node-packages/node-env.nix"'
sed -i "s|import ./node-env.nix|$nodeEnvImport|" composition.nix
sed -i "
s|\bversion = .*;|version = \"$version\";|
s|\bhash = .*;|hash = \"$hash\";|
" default.nix
}
# Use the verified package src
read -d '' fetchurl <<EOF || :
fetchurl {
url = "$url";
hash = "$hash";
};
EOF
sed -i "s|src = .*/src;|src = ${fetchurl//$'\n'/\\n}|" node-packages.nix
updateNodeModulesHash() {
$scriptDir/../../helper/update-fixed-output-derivation.sh ./default.nix clightning-rest.nodeModules nodeModules
}
if [[ $# == 0 ]]; then
# Each of these can be run separately
updateSrc
updateNodeModulesHash
else
eval "$@"
fi