1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl jq libarchive
6 nixpkgs
=..
/..
/..
/..
/..
/..
/
7 node_packages
="$nixpkgs/pkgs/development/node-packages"
11 curl
-s "https://api.github.com/repos/$owner/$repo/releases" |
12 jq
'map(select(.prerelease | not)) | .[0].tag_name' --raw-output
14 node_src
="$(nix-build "$nixpkgs" -A rust-analyzer.src --no-out-link)/editors/code"
16 # Check vscode compatibility
17 req_vscode_ver
="$(jq '.engines.vscode' "$node_src/package.json
" --raw-output)"
18 req_vscode_ver
="${req_vscode_ver#^}"
19 cur_vscode_ver
="$(nix-instantiate --eval --strict "$nixpkgs" -A vscode.version | tr -d '"')"
20 if [[ "$(nix-instantiate --eval --strict -E "(builtins.compareVersions \"$req_vscode_ver\" \"$cur_vscode_ver\")")" -gt 0 ]]; then
21 echo "vscode $cur_vscode_ver is incompatible with the extension requiring ^$req_vscode_ver"
25 extension_ver=$(curl "https://github.com/$owner/$repo/releases/download/$ver/rust-analyzer-linux-x64.vsix" -L |
26 bsdtar -xf - --to-stdout extension/package.json | # Use bsdtar to extract vsix(zip).
27 jq --raw-output '.version
')
28 echo "Extension version: $extension_ver"
30 # We need devDependencies to build vsix.
31 # `esbuild` is a binary package an is already in nixpkgs so we omit it here.
32 jq '{ name
, version
: $ver, dependencies
: (.dependencies
+ .devDependencies | del
(.esbuild
)) }' "$node_src/package.json" \
33 --arg ver "$extension_ver" \
34 >"build-deps/package.json.new"
36 old_deps="$(jq '.dependencies
' build-deps/package.json)"
37 new_deps="$(jq '.dependencies
' build-deps/package.json.new)"
38 if [[ "$old_deps" == "$new_deps" ]]; then
39 echo "package.json dependencies not changed, do simple version change"
41 sed -E '/^
"rust-analyzer-build-deps/,+3 s/version = ".
*"/version = "'"$extension_ver"'"/' \
42 --in-place "$node_packages"/node-packages.nix
43 mv build-deps/package.json{.new,}
45 echo "package.json dependencies changed
, updating nodePackages
"
46 mv build-deps/package.json{.new,}
48 ./"$node_packages"/generate.sh
51 echo "Remember to also update the releaseTag and
hash in default.nix
!"