Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1#! /usr/bin/env nix-shell
2#! nix-shell -i bash -p gnused jq nix-prefetch-github nodejs prefetch-npm-deps wget
3
4set -euo pipefail
5pushd "$(dirname "${BASH_SOURCE[0]}")"
6
7version=$(npm view node-gyp version)
8
9if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then
10 echo "Already up to date!"
11 exit 0
12fi
13
14sed -i 's#version = "[^"]*"#version = "'"$version"'"#' package.nix
15
16src_hash=$(nix-prefetch-github nodejs node-gyp --rev "v$version" | jq --raw-output .hash)
17sed -i 's#hash = "[^"]*"#hash = "'"$src_hash"'"#' package.nix
18
19rm -f package-lock.json package.json
20wget "https://github.com/nodejs/node-gyp/raw/v$version/package.json"
21npm i --package-lock-only --ignore-scripts
22npm_hash=$(prefetch-npm-deps package-lock.json)
23sed -i 's#npmDepsHash = "[^"]*"#npmDepsHash = "'"$npm_hash"'"#' package.nix
24rm package.json
25
26popd