From d4e758c5ac02126e30abcb8a2c72cde18f661a8e Mon Sep 17 00:00:00 2001 From: oxalica Date: Fri, 9 Apr 2021 00:49:27 +0800 Subject: [PATCH 1/3] rust-analyzer: 2021-03-22 -> 2021-04-05 --- .../tools/rust/rust-analyzer/default.nix | 6 +++--- .../tools/rust/rust-analyzer/generic.nix | 2 -- .../tools/rust/rust-analyzer/rust_1_49.patch | 13 ------------- 3 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 pkgs/development/tools/rust/rust-analyzer/rust_1_49.patch diff --git a/pkgs/development/tools/rust/rust-analyzer/default.nix b/pkgs/development/tools/rust/rust-analyzer/default.nix index d8b31810c54..571919690b1 100644 --- a/pkgs/development/tools/rust/rust-analyzer/default.nix +++ b/pkgs/development/tools/rust/rust-analyzer/default.nix @@ -2,10 +2,10 @@ { rust-analyzer-unwrapped = callPackage ./generic.nix rec { - rev = "2021-03-22"; + rev = "2021-04-05"; version = "unstable-${rev}"; - sha256 = "sha256-Q8yr5x4+R9UCk5kw/nJgBtGVBeZTDwyuwpyNJUKSPzA="; - cargoSha256 = "sha256-cJ5KPNrX1H4IfHENDGyU2rgxl5TTqvoeXk7558oqwuA="; + sha256 = "sha256-ZDxy87F3uz8bTF1/2LIy5r4Nv/M3xe97F7mwJNEFcUs="; + cargoSha256 = "sha256-kDwdKa08E0h24lOOa7ALeNqHlMjMry/ru1qwCIyKmuE="; inherit CoreServices; }; diff --git a/pkgs/development/tools/rust/rust-analyzer/generic.nix b/pkgs/development/tools/rust/rust-analyzer/generic.nix index ddb834af6c3..80816c6a636 100644 --- a/pkgs/development/tools/rust/rust-analyzer/generic.nix +++ b/pkgs/development/tools/rust/rust-analyzer/generic.nix @@ -46,8 +46,6 @@ rustPlatform.buildRustPackage { passthru.updateScript = ./update.sh; - patches = [ ./rust_1_49.patch ]; - meta = with lib; { description = "An experimental modular compiler frontend for the Rust language"; homepage = "https://github.com/rust-analyzer/rust-analyzer"; diff --git a/pkgs/development/tools/rust/rust-analyzer/rust_1_49.patch b/pkgs/development/tools/rust/rust-analyzer/rust_1_49.patch deleted file mode 100644 index fcde6d6337e..00000000000 --- a/pkgs/development/tools/rust/rust-analyzer/rust_1_49.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs -index 4e75a7b14..91f51a1a7 100644 ---- a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs -+++ b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs -@@ -93,7 +93,7 @@ fn validate_method_call_expr( - let krate = module.krate(); - - let iter_trait = FamousDefs(sema, Some(krate)).core_iter_Iterator()?; -- it_type.impls_trait(sema.db, iter_trait, &[]).then(|| (expr, receiver)) -+ if it_type.impls_trait(sema.db, iter_trait, &[]) { Some((expr, receiver)) } else { None } - } - - #[cfg(test)] From 6efb930e1844da28cac7d6059a65969f41190d8a Mon Sep 17 00:00:00 2001 From: oxalica Date: Mon, 12 Apr 2021 01:35:08 +0800 Subject: [PATCH 2/3] rust-analyzer: merge version specific fields into generic derivation --- .../tools/rust/rust-analyzer/default.nix | 16 --------------- .../tools/rust/rust-analyzer/generic.nix | 13 +++++++----- .../tools/rust/rust-analyzer/update.sh | 2 +- .../tools/rust/rust-analyzer/wrapper.nix | 20 +++++++++---------- pkgs/top-level/all-packages.nix | 6 +++--- 5 files changed, 21 insertions(+), 36 deletions(-) delete mode 100644 pkgs/development/tools/rust/rust-analyzer/default.nix diff --git a/pkgs/development/tools/rust/rust-analyzer/default.nix b/pkgs/development/tools/rust/rust-analyzer/default.nix deleted file mode 100644 index 571919690b1..00000000000 --- a/pkgs/development/tools/rust/rust-analyzer/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ pkgs, callPackage, CoreServices }: - -{ - rust-analyzer-unwrapped = callPackage ./generic.nix rec { - rev = "2021-04-05"; - version = "unstable-${rev}"; - sha256 = "sha256-ZDxy87F3uz8bTF1/2LIy5r4Nv/M3xe97F7mwJNEFcUs="; - cargoSha256 = "sha256-kDwdKa08E0h24lOOa7ALeNqHlMjMry/ru1qwCIyKmuE="; - - inherit CoreServices; - }; - - rust-analyzer = callPackage ./wrapper.nix {} { - unwrapped = pkgs.rust-analyzer-unwrapped; - }; -} diff --git a/pkgs/development/tools/rust/rust-analyzer/generic.nix b/pkgs/development/tools/rust/rust-analyzer/generic.nix index 80816c6a636..cb10b8196aa 100644 --- a/pkgs/development/tools/rust/rust-analyzer/generic.nix +++ b/pkgs/development/tools/rust/rust-analyzer/generic.nix @@ -2,19 +2,22 @@ , libiconv , useMimalloc ? false , doCheck ? true - -# Version specific args -, rev, version, sha256, cargoSha256 }: +let + rev = "2021-04-05"; +in + rustPlatform.buildRustPackage { pname = "rust-analyzer-unwrapped"; - inherit version cargoSha256; + version = "unstable-${rev}"; + cargoSha256 = "sha256-kDwdKa08E0h24lOOa7ALeNqHlMjMry/ru1qwCIyKmuE="; src = fetchFromGitHub { owner = "rust-analyzer"; repo = "rust-analyzer"; - inherit rev sha256; + inherit rev; + sha256 = "sha256-ZDxy87F3uz8bTF1/2LIy5r4Nv/M3xe97F7mwJNEFcUs="; }; buildAndTestSubdir = "crates/rust-analyzer"; diff --git a/pkgs/development/tools/rust/rust-analyzer/update.sh b/pkgs/development/tools/rust/rust-analyzer/update.sh index 1bd46862692..185ce70534c 100755 --- a/pkgs/development/tools/rust/rust-analyzer/update.sh +++ b/pkgs/development/tools/rust/rust-analyzer/update.sh @@ -25,7 +25,7 @@ echo "$old_rev -> $rev" sha256=$(nix-prefetch -f "$nixpkgs" rust-analyzer-unwrapped.src --rev "$rev") # Clear cargoSha256 to avoid inconsistency. sed -e "s#rev = \".*\"#rev = \"$rev\"#" \ - -e "s#sha256 = \".*\"#sha256 = \"$sha256\"#" \ + -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" diff --git a/pkgs/development/tools/rust/rust-analyzer/wrapper.nix b/pkgs/development/tools/rust/rust-analyzer/wrapper.nix index bed20628182..6fa5207de6e 100644 --- a/pkgs/development/tools/rust/rust-analyzer/wrapper.nix +++ b/pkgs/development/tools/rust/rust-analyzer/wrapper.nix @@ -1,17 +1,15 @@ -{ lib, rustPlatform, runCommandNoCC, makeWrapper }: - -lib.makeOverridable ({ - unwrapped, - pname ? "rust-analyzer", - version ? unwrapped.version, +{ lib, rustPlatform, runCommand, makeWrapper, rust-analyzer-unwrapped +, pname ? "rust-analyzer" +, version ? rust-analyzer-unwrapped.version # Use name from `RUST_SRC_PATH` - rustSrc ? rustPlatform.rustLibSrc, -}: runCommandNoCC "${pname}-${version}" { +, rustSrc ? rustPlatform.rustLibSrc +}: +runCommand "${pname}-${version}" { inherit pname version; - inherit (unwrapped) src meta; + inherit (rust-analyzer-unwrapped) src meta; nativeBuildInputs = [ makeWrapper ]; } '' mkdir -p $out/bin - makeWrapper ${unwrapped}/bin/rust-analyzer $out/bin/rust-analyzer \ + makeWrapper ${rust-analyzer-unwrapped}/bin/rust-analyzer $out/bin/rust-analyzer \ --set-default RUST_SRC_PATH "${rustSrc}" -'') +'' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8b430c40cc8..12a1b126957 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11321,10 +11321,10 @@ in rustracerd = callPackage ../development/tools/rust/racerd { inherit (darwin.apple_sdk.frameworks) Security; }; - inherit (callPackage ../development/tools/rust/rust-analyzer { + rust-analyzer-unwrapped = callPackage ../development/tools/rust/rust-analyzer { inherit (darwin.apple_sdk.frameworks) CoreServices; - }) - rust-analyzer-unwrapped rust-analyzer; + }; + rust-analyzer = callPackage ../development/tools/rust/rust-analyzer/wrapper.nix { }; rust-bindgen = callPackage ../development/tools/rust/bindgen { }; rust-cbindgen = callPackage ../development/tools/rust/cbindgen { inherit (darwin.apple_sdk.frameworks) Security; From 501284ea42d909ecd5bd8e0ca82482a2fc6afb61 Mon Sep 17 00:00:00 2001 From: oxalica Date: Mon, 12 Apr 2021 01:49:05 +0800 Subject: [PATCH 3/3] rust-analyzer: rename nix file --- .../tools/rust/rust-analyzer/{generic.nix => default.nix} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pkgs/development/tools/rust/rust-analyzer/{generic.nix => default.nix} (100%) diff --git a/pkgs/development/tools/rust/rust-analyzer/generic.nix b/pkgs/development/tools/rust/rust-analyzer/default.nix similarity index 100% rename from pkgs/development/tools/rust/rust-analyzer/generic.nix rename to pkgs/development/tools/rust/rust-analyzer/default.nix