1{
2 lib,
3 writeScript,
4 common-updater-scripts,
5 coreutils,
6 curl,
7 fetchurl,
8 gnugrep,
9 gnupg,
10 jq,
11 majorVersion,
12 runtimeShell,
13}:
14
15let
16 rev = "901fc09b83c686693be51b3c9a13578929cbc1ab"; # should be the HEAD of nodejs/release-keys
17 pubring = fetchurl {
18 url = "https://github.com/nodejs/release-keys/raw/${rev}/gpg-only-active-keys/pubring.kbx";
19 hash = "sha256-r/thHVLDlMVRN3Ahr5Apivy+h2IuvPm4QhYFoAmms3E=";
20 };
21in
22writeScript "update-nodejs" ''
23 #!${runtimeShell}
24
25 set -e
26 set -o pipefail
27
28 PATH=${
29 lib.makeBinPath [
30 common-updater-scripts
31 coreutils
32 curl
33 gnugrep
34 gnupg
35 jq
36 ]
37 }
38
39 version=`\
40 curl --silent https://api.github.com/repos/nodejs/node/git/refs/tags | \
41 jq -r '.[] | select(.ref | startswith("refs/tags/v${majorVersion}")) | .ref' | \
42 sort --version-sort | \
43 tail -1 | \
44 grep -oP "^refs/tags/v\K.*"`
45
46 hash_hex=`
47 curl --silent "https://nodejs.org/dist/v''${version}/SHASUMS256.txt.asc" | \
48 gpgv --keyring="${pubring}" --output - | \
49 grep -oP "^([0-9a-f]{64})(?=\s+node-v''${version}.tar.xz$)"`
50
51 update-source-version nodejs_${majorVersion} "''${version}" "''${hash_hex}"
52''