Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / web / nodejs / update.nix
blobebe6a74c26967091f97846654224ff0a83512d00
1 { lib
2 , writeScript
3 , coreutils
4 , curl
5 , gnugrep
6 , jq
7 , gnupg
8 , common-updater-scripts
9 , majorVersion
10 , nix
11 , runtimeShell
14 writeScript "update-nodejs" ''
15   #!${runtimeShell}
16   PATH=${lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep jq gnupg nix ]}
18   HOME=`mktemp -d`
19   cat ${./nodejs-release-keys.asc} | gpg --import
21   tags=`curl --silent https://api.github.com/repos/nodejs/node/git/refs/tags`
22   version=`echo $tags | jq -r '.[] | select(.ref | startswith("refs/tags/v${majorVersion}")) | .ref' | sort --version-sort  | tail -1 | grep -oP "^refs/tags/v\K.*"`
24   curl --silent -o $HOME/SHASUMS256.txt.asc https://nodejs.org/dist/v''${version}/SHASUMS256.txt.asc
25   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$)"`
26   hash=`nix-hash --type sha256 --to-base32 ''${hash_hex}`
28   update-source-version nodejs_${majorVersion} "''${version}" "''${hash}"