2021-11-08 03:41:42 -08:00
|
|
|
#!/usr/bin/env nix-shell
|
2021-12-14 10:51:19 -08:00
|
|
|
#! nix-shell -i bash -p nodePackages.node2nix gnupg wget jq gnused
|
2021-11-08 03:41:42 -08:00
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
TMPDIR="$(mktemp -d -p /tmp)"
|
|
|
|
trap "rm -rf $TMPDIR" EXIT
|
|
|
|
|
|
|
|
version="0.11.2"
|
2021-12-14 10:51:19 -08:00
|
|
|
repo=https://github.com/Ride-The-Lightning/RTL
|
|
|
|
|
|
|
|
# Fetch and verify source tarball
|
|
|
|
file=v${version}.tar.gz
|
|
|
|
url=$repo/archive/refs/tags/$file
|
2021-11-08 03:41:42 -08:00
|
|
|
export GNUPGHOME=$TMPDIR
|
|
|
|
gpg --keyserver hkps://keyserver.ubuntu.com --recv-key 3E9BD4436C288039CA827A9200C9E2BC2E45666F
|
2021-12-14 10:51:19 -08:00
|
|
|
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)
|
|
|
|
|
|
|
|
# Extract source
|
|
|
|
src=$TMPDIR/src
|
|
|
|
mkdir $src
|
|
|
|
tar xvf $TMPDIR/$file -C $src --strip-components 1 >/dev/null
|
2021-11-08 03:41:42 -08:00
|
|
|
|
2021-12-14 10:51:19 -08:00
|
|
|
# Generate nix pkg
|
|
|
|
node2nix \
|
|
|
|
--input $src/package.json \
|
|
|
|
--lock $src/package-lock.json \
|
|
|
|
--composition composition.nix \
|
|
|
|
--no-copy-node-env
|
2021-11-08 03:41:42 -08:00
|
|
|
|
2021-12-14 10:51:19 -08:00
|
|
|
# Use node-env.nix from nixpkgs
|
2021-11-08 03:41:42 -08:00
|
|
|
nodeEnvImport='import "${toString pkgs.path}/pkgs/development/node-packages/node-env.nix"'
|
|
|
|
sed -i "s|import ./node-env.nix|$nodeEnvImport|" composition.nix
|
|
|
|
|
2021-12-14 10:51:19 -08:00
|
|
|
# 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
|