Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1#!/usr/bin/env nix-shell 2#!nix-shell -i bash -p curl jq libarchive 3#shellcheck shell=bash 4set -euo pipefail 5cd "$(dirname "$0")" 6nixpkgs=../../../../../../ 7owner=rust-lang 8repo=rust-analyzer 9ver=$( 10 curl -s "https://api.github.com/repos/$owner/$repo/releases" | 11 jq 'map(select(.prerelease | not)) | .[0].tag_name' --raw-output 12) 13node_src="$(nix-build "$nixpkgs" -A rust-analyzer.src --no-out-link)/editors/code" 14 15# Check vscode compatibility 16req_vscode_ver="$(jq '.engines.vscode' "$node_src/package.json" --raw-output)" 17req_vscode_ver="${req_vscode_ver#^}" 18cur_vscode_ver="$(nix-instantiate --eval --strict "$nixpkgs" -A vscode.version | tr -d '"')" 19if [[ "$(nix-instantiate --eval --strict -E "(builtins.compareVersions \"$req_vscode_ver\" \"$cur_vscode_ver\")")" -gt 0 ]]; then 20 echo "vscode $cur_vscode_ver is incompatible with the extension requiring ^$req_vscode_ver" 21 exit 1 22fi 23 24extension_ver=$(curl "https://github.com/$owner/$repo/releases/download/$ver/rust-analyzer-linux-x64.vsix" -L | 25 bsdtar -xf - --to-stdout extension/package.json | # Use bsdtar to extract vsix(zip). 26 jq --raw-output '.version') 27echo -n $extension_ver > version.txt 28echo "Extension version: $extension_ver" 29 30echo "Remember to also update the releaseTag and hash in default.nix!"