From bde9289415bae0e62e67072e22f5666da4c3a9f5 Mon Sep 17 00:00:00 2001 From: oxalica Date: Tue, 17 Mar 2020 17:56:26 +0800 Subject: [PATCH] rust-analyzer: check compatibility in update script --- pkgs/development/tools/rust/rust-analyzer/update.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkgs/development/tools/rust/rust-analyzer/update.sh b/pkgs/development/tools/rust/rust-analyzer/update.sh index 3b4212fd9a04..5406de00ef32 100755 --- a/pkgs/development/tools/rust/rust-analyzer/update.sh +++ b/pkgs/development/tools/rust/rust-analyzer/update.sh @@ -27,6 +27,16 @@ sed -e "s/rev = \".*\"/rev = \"$rev\"/" \ -e "s/sha256 = \".*\"/sha256 = \"$sha256\"/" \ -e "s/cargoSha256 = \".*\"/cargoSha256 = \"0000000000000000000000000000000000000000000000000000\"/" \ --in-place ./default.nix +node_src="$(nix-build "$nixpkgs" -A rust-analyzer.src --no-out-link)/editors/code" + +# Check vscode compatibility +req_vscode_ver="$(jq '.engines.vscode' "$node_src/package.json" --raw-output)" +req_vscode_ver="${req_vscode_ver#^}" +cur_vscode_ver="$(nix eval --raw -f "$nixpkgs" vscode.version)" +if [[ "$(nix eval "(builtins.compareVersions \"$req_vscode_ver\" \"$cur_vscode_ver\")")" != "-1" ]]; then + echo "vscode $cur_vscode_ver is incompatible with the extension requiring ^$req_vscode_ver" + exit 1 +fi echo "Prebuilding nix" cargo_sha256=$({ @@ -40,7 +50,6 @@ sed "s/cargoSha256 = \".*\"/cargoSha256 = \"$cargo_sha256\"/" \ # Update vscode extension echo "Generating node lock" -node_src="$(nix-build "$nixpkgs" -A rust-analyzer.src --no-out-link)/editors/code" pushd "$nixpkgs/pkgs/misc/vscode-extensions/rust-analyzer" ext_version=$(jq '.version' "$node_src/package.json" --raw-output) ext_publisher=$(jq '.publisher' "$node_src/package.json" --raw-output)