diff --git a/pkgs/rtl/composition.nix b/pkgs/rtl/composition.nix index f49b28e..01c4b77 100644 --- a/pkgs/rtl/composition.nix +++ b/pkgs/rtl/composition.nix @@ -2,7 +2,7 @@ {pkgs ? import { inherit system; - }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-10_x"}: + }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-12_x"}: let nodeEnv = import "${toString pkgs.path}/pkgs/development/node-packages/node-env.nix" { diff --git a/pkgs/rtl/default.nix b/pkgs/rtl/default.nix index ea6f456..b7931b7 100644 --- a/pkgs/rtl/default.nix +++ b/pkgs/rtl/default.nix @@ -1,5 +1,5 @@ -{ stdenv, pkgs, lib }: -lib.head (builtins.attrValues (import ./composition.nix { - inherit pkgs; - inherit (stdenv.hostPlatform) system; -})) +{ pkgs }: +let + nodePackages = import ./composition.nix { inherit pkgs; inherit (pkgs) nodejs; }; +in +nodePackages.package diff --git a/pkgs/rtl/generate.sh b/pkgs/rtl/generate.sh index 1a32cc1..8a1c256 100755 --- a/pkgs/rtl/generate.sh +++ b/pkgs/rtl/generate.sh @@ -1,31 +1,44 @@ #!/usr/bin/env nix-shell -#! nix-shell -i bash -p nodePackages.node2nix gnupg wget jq moreutils +#! nix-shell -i bash -p nodePackages.node2nix gnupg wget jq gnused set -euo pipefail TMPDIR="$(mktemp -d -p /tmp)" trap "rm -rf $TMPDIR" EXIT -# Get/verify source tarball version="0.11.2" +repo=https://github.com/Ride-The-Lightning/RTL + +# 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 https://github.com/Ride-The-Lightning/RTL/archive/refs/tags/v${version}.tar.gz -wget -P $TMPDIR https://github.com/Ride-The-Lightning/RTL/releases/download/v${version}/v${version}.tar.gz.asc -gpg --verify $TMPDIR/v${version}.tar.gz.asc $TMPDIR/v${version}.tar.gz -shasum=$(sha256sum $TMPDIR/v${version}.tar.gz | cut -d\ -f1) +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) -# Run node2nix -mkdir $TMPDIR/package && tar xvf $TMPDIR/v${version}.tar.gz -C $TMPDIR/package --strip-components 1 -cp pkg.json $TMPDIR/pkg.json -node2nix --nodejs-10 -i $TMPDIR/pkg.json -c composition.nix --no-copy-node-env +# Extract source +src=$TMPDIR/src +mkdir $src +tar xvf $TMPDIR/$file -C $src --strip-components 1 >/dev/null -# Set node env import. -# The reason for not providing a custom node-env.nix file is the following: -# To be flakes-compatible, we have to locate the nixpgs source via `pkgs.path` instead of ``. -# This requires the `pkgs` variable which is available only in composition.nix, not in node-env.nix. +# Generate nix pkg +node2nix \ + --input $src/package.json \ + --lock $src/package-lock.json \ + --composition composition.nix \ + --no-copy-node-env + +# 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 -# Use verified source in node-packages.nix -url="https://github.com/Ride-The-Lightning/RTL/archive/refs/tags/v$version.tar.gz" -sed -i '/packageName = "rtl";/!b;n;n;c\ src = fetchurl {\n url = "'$url'";\n sha256 = "'$shasum'";\n };' node-packages.nix +# Use the verified package src +read -d '' fetchurl <