dadc7eb329
Whenever we create scripts that are installed to $out, we must use runtimeShell in order to get the shell that can be executed on the machine we create the package for. This is relevant for cross-compiling. The only use case for stdenv.shell are scripts that are executed as part of the build system. Usages in checkPhase are borderline however to decrease the likelyhood of people copying the wrong examples, I decided to use runtimeShell as well.
31 lines
981 B
Nix
31 lines
981 B
Nix
{ stdenv
|
|
, lib
|
|
, writeScript
|
|
, coreutils
|
|
, curl
|
|
, gnugrep
|
|
, jq
|
|
, gnupg
|
|
, common-updater-scripts
|
|
, majorVersion
|
|
, nix
|
|
, runtimeShell
|
|
}:
|
|
|
|
writeScript "update-nodejs" ''
|
|
#!${runtimeShell}
|
|
PATH=${lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep jq gnupg nix ]}
|
|
|
|
HOME=`mktemp -d`
|
|
cat ${./nodejs-release-keys.asc} | gpg --import
|
|
|
|
tags=`curl --silent https://api.github.com/repos/nodejs/node/git/refs/tags`
|
|
version=`echo $tags | jq -r '.[] | select(.ref | startswith("refs/tags/v${majorVersion}")) | .ref' | sort --version-sort | tail -1 | grep -oP "^refs/tags/v\K.*"`
|
|
|
|
curl --silent -o $HOME/SHASUMS256.txt.asc https://nodejs.org/dist/v''${version}/SHASUMS256.txt.asc
|
|
hash_hex=`gpgv --keyring=$HOME/.gnupg/pubring.kbx --output - $HOME/SHASUMS256.txt.asc | grep -oP "^([0-9a-f]{64})(?=\s+node-v''${version}.tar.xz$)"`
|
|
hash=`nix-hash --type sha256 --to-base32 ''${hash_hex}`
|
|
|
|
update-source-version nodejs-${majorVersion}_x "''${version}" "''${hash}"
|
|
''
|