From d8c8e3f6d1df88d4b8c211d19e1ba4773085a7f7 Mon Sep 17 00:00:00 2001 From: oxalica Date: Wed, 15 Dec 2021 05:52:46 +0800 Subject: [PATCH 1/2] vscode-extensions.matklad.rust-analyzer: split from rust-analyzer Also remove oxalica from maintainers. --- .../tools/rust/rust-analyzer/update.sh | 42 ------------------- .../rust-analyzer/default.nix | 23 ++++++---- 2 files changed, 16 insertions(+), 49 deletions(-) diff --git a/pkgs/development/tools/rust/rust-analyzer/update.sh b/pkgs/development/tools/rust/rust-analyzer/update.sh index add400e4d0e8..920b36a5131e 100755 --- a/pkgs/development/tools/rust/rust-analyzer/update.sh +++ b/pkgs/development/tools/rust/rust-analyzer/update.sh @@ -28,50 +28,8 @@ sed -e "s#version = \".*\"#version = \"$ver\"#" \ -e "/fetchFromGitHub/,/}/ s#sha256 = \".*\"#sha256 = \"$sha256\"#" \ -e "s#cargoSha256 = \".*\"#cargoSha256 = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"#" \ --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-instantiate --eval --strict "$nixpkgs" -A vscode.version | tr -d '"')" -if [[ "$(nix-instantiate --eval --strict -E "(builtins.compareVersions \"$req_vscode_ver\" \"$cur_vscode_ver\")")" -gt 0 ]]; then - echo "vscode $cur_vscode_ver is incompatible with the extension requiring ^$req_vscode_ver" - exit 1 -fi echo "Prebuilding for cargoSha256" cargo_sha256=$(nix-prefetch "{ sha256 }: (import $nixpkgs {}).rust-analyzer-unwrapped.cargoDeps.overrideAttrs (_: { outputHash = sha256; })") sed "s#cargoSha256 = \".*\"#cargoSha256 = \"$cargo_sha256\"#" \ --in-place ./default.nix - -# Update vscode extension - -extension_ver=$(curl "https://github.com/rust-analyzer/rust-analyzer/releases/download/$ver/rust-analyzer.vsix" -L | - bsdtar -xf - --to-stdout extension/package.json | # Use bsdtar to extract vsix(zip). - jq --raw-output '.version') -echo "Extension version: $extension_ver" - -build_deps="../../../../misc/vscode-extensions/rust-analyzer/build-deps" -# We need devDependencies to build vsix. -# `esbuild` is a binary package an is already in nixpkgs so we omit it here. -jq '{ name, version: $ver, dependencies: (.dependencies + .devDependencies | del(.esbuild)) }' "$node_src/package.json" \ - --arg ver "$extension_ver" \ - >"$build_deps/package.json.new" - -old_deps="$(jq '.dependencies' "$build_deps"/package.json)" -new_deps="$(jq '.dependencies' "$build_deps"/package.json.new)" -if [[ "$old_deps" == "$new_deps" ]]; then - echo "package.json dependencies not changed, do simple version change" - - sed -E '/^ "rust-analyzer-build-deps/,+3 s/version = ".*"/version = "'"$extension_ver"'"/' \ - --in-place ../../../node-packages/node-packages.nix - mv "$build_deps"/package.json{.new,} - -else - echo "package.json dependencies changed, updating nodePackages" - mv "$build_deps"/package.json{.new,} - - pushd "../../../node-packages" - ./generate.sh - popd -fi diff --git a/pkgs/misc/vscode-extensions/rust-analyzer/default.nix b/pkgs/misc/vscode-extensions/rust-analyzer/default.nix index 668d87767803..0580fc7d56ae 100644 --- a/pkgs/misc/vscode-extensions/rust-analyzer/default.nix +++ b/pkgs/misc/vscode-extensions/rust-analyzer/default.nix @@ -1,5 +1,5 @@ -# Update script: pkgs/development/tools/rust/rust-analyzer/update.sh { lib +, fetchFromGitHub , vscode-utils , jq , rust-analyzer @@ -15,14 +15,26 @@ let pname = "rust-analyzer"; publisher = "matklad"; + # Use the plugin version as in vscode marketplace, updated by update script. + inherit (vsix) version; + + releaseTag = "2021-11-29"; + + src = fetchFromGitHub { + owner = "rust-analyzer"; + repo = "rust-analyzer"; + rev = releaseTag; + sha256 = "sha256-vh7z8jupVxXPOko3sWUsOB7eji/7lKfwJ/CE3iw97Sw="; + }; + build-deps = nodePackages."rust-analyzer-build-deps-../../misc/vscode-extensions/rust-analyzer/build-deps"; # FIXME: Making a new derivation to link `node_modules` and run `npm run package` # will cause a build failure. vsix = build-deps.override { - src = "${rust-analyzer.src}/editors/code"; + src = "${src}/editors/code"; outputs = [ "vsix" "out" ]; - releaseTag = rust-analyzer.version; + inherit releaseTag; nativeBuildInputs = [ jq moreutils esbuild @@ -46,9 +58,6 @@ let ''; }; - # Use the plugin version as in vscode marketplace, updated by update script. - inherit (vsix) version; - in vscode-utils.buildVscodeExtension { inherit version vsix; @@ -68,7 +77,7 @@ vscode-utils.buildVscodeExtension { description = "An alternative rust language server to the RLS"; homepage = "https://github.com/rust-analyzer/rust-analyzer"; license = with licenses; [ mit asl20 ]; - maintainers = with maintainers; [ oxalica ]; + maintainers = with maintainers; [ ]; platforms = platforms.all; }; } From dfc31f4c83966325a0e1c003de6ad0bee80e8cc5 Mon Sep 17 00:00:00 2001 From: oxalica Date: Wed, 15 Dec 2021 06:17:45 +0800 Subject: [PATCH 2/2] rust-analyzer: 2021-11-29 -> 2021-12-13 --- .../tools/rust/rust-analyzer/default.nix | 9 ++++++--- .../rust-analyzer/no-1-57-map-while.patch | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/tools/rust/rust-analyzer/no-1-57-map-while.patch diff --git a/pkgs/development/tools/rust/rust-analyzer/default.nix b/pkgs/development/tools/rust/rust-analyzer/default.nix index fdc91503ff5c..d08f2acb9dec 100644 --- a/pkgs/development/tools/rust/rust-analyzer/default.nix +++ b/pkgs/development/tools/rust/rust-analyzer/default.nix @@ -11,20 +11,23 @@ rustPlatform.buildRustPackage rec { pname = "rust-analyzer-unwrapped"; - version = "2021-11-29"; - cargoSha256 = "sha256-UgYR0e3Pt3lcbkSDnizlwtwjnqTaqGlXRgR724U4rSU="; + version = "2021-12-13"; + cargoSha256 = "sha256-VF4pwSl3Wei7KxyQFOPj7hVX/NG2zImRLv4iN+ijAs8="; src = fetchFromGitHub { owner = "rust-analyzer"; repo = "rust-analyzer"; rev = version; - sha256 = "sha256-vh7z8jupVxXPOko3sWUsOB7eji/7lKfwJ/CE3iw97Sw="; + sha256 = "sha256-xt7iDfIoaBhStgqsgttyOFF4NYPQ8jeVwDoYUwrvtrA="; }; patches = [ # Code format and git history check require more dependencies but don't really matter for packaging. # So just ignore them. ./ignore-git-and-rustfmt-tests.patch + + # Remove when we have rustc >= 1.57.0. + ./no-1-57-map-while.patch ]; buildAndTestSubdir = "crates/rust-analyzer"; diff --git a/pkgs/development/tools/rust/rust-analyzer/no-1-57-map-while.patch b/pkgs/development/tools/rust/rust-analyzer/no-1-57-map-while.patch new file mode 100644 index 000000000000..6114f51831be --- /dev/null +++ b/pkgs/development/tools/rust/rust-analyzer/no-1-57-map-while.patch @@ -0,0 +1,20 @@ +--- a/crates/ide_db/src/helpers.rs ++++ b/crates/ide_db/src/helpers.rs +@@ -309,7 +309,7 @@ pub fn lint_eq_or_in_group(lint: &str, lint_is: &str) -> bool { + pub fn parse_tt_as_comma_sep_paths(input: ast::TokenTree) -> Option> { + let r_paren = input.r_paren_token(); + let tokens = +- input.syntax().children_with_tokens().skip(1).map_while(|it| match it.into_token() { ++ input.syntax().children_with_tokens().skip(1).map(|it| match it.into_token() { + // seeing a keyword means the attribute is unclosed so stop parsing here + Some(tok) if tok.kind().is_keyword() => None, + // don't include the right token tree parenthesis if it exists +@@ -317,7 +317,7 @@ pub fn parse_tt_as_comma_sep_paths(input: ast::TokenTree) -> Option None, + Some(tok) => Some(tok), +- }); ++ }).take_while(|tok| tok.is_some()).map(|tok| tok.unwrap()); + let input_expressions = tokens.into_iter().group_by(|tok| tok.kind() == T![,]); + let paths = input_expressions + .into_iter()