Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust-analyzer: 2020-10-19 -> 2020-11-09 and fix build #101773

Merged
merged 4 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkgs/development/compilers/rust/make-rust-platform.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ rec {
rustcSrc = callPackage ./rust-src.nix {
inherit rustc;
};

rustLibSrc = callPackage ./rust-lib-src.nix {
inherit rustc;
};
}
11 changes: 11 additions & 0 deletions pkgs/development/compilers/rust/rust-lib-src.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ stdenv, rustc }:

stdenv.mkDerivation {
name = "rust-lib-src";
src = rustc.src;
phases = [ "unpackPhase" "installPhase" ];

installPhase = ''
mv library $out
'';
}
2,268 changes: 908 additions & 1,360 deletions pkgs/development/node-packages/node-packages.nix

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pkgs/development/tools/rust/rust-analyzer/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

{
rust-analyzer-unwrapped = callPackage ./generic.nix rec {
rev = "2020-10-19";
rev = "2020-11-09";
version = "unstable-${rev}";
sha256 = "1xvyk1d26zn1d9i42h78qsm6bg57nhn1rgr46jwa46gsb31nabjh";
cargoSha256 = "18s5yrc9fdj2ndylwyf07l0kmwxka7mnbj254xmq3g7ragw71xjw";
sha256 = "sha256-SX9dvx2JtYZBxA3+dHQKX/jrjbAMy37/SAybDjlYcSs=";
cargoSha256 = "sha256-+td+wMmI+MyGz9oPC+SPO2TmAV0+3lOORNY7xf6s3vI=";
};

rust-analyzer = callPackage ./wrapper.nix {} {
Expand Down
7 changes: 1 addition & 6 deletions pkgs/development/tools/rust/rust-analyzer/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ rustPlatform.buildRustPackage {
inherit rev sha256;
};

# FIXME: Temporary fixes for our rust 1.46.0
patches = [
./no-track_env_var.patch # Requires rustc 1.47.0
];

buildAndTestSubdir = "crates/rust-analyzer";

cargoBuildFlags = lib.optional useMimalloc "--features=mimalloc";
Expand All @@ -34,7 +29,7 @@ rustPlatform.buildRustPackage {

inherit doCheck;
preCheck = lib.optionalString doCheck ''
export RUST_SRC_PATH=${rustPlatform.rustcSrc}
export RUST_SRC_PATH=${rustPlatform.rustLibSrc}
'';

doInstallCheck = true;
Expand Down
120 changes: 0 additions & 120 deletions pkgs/development/tools/rust/rust-analyzer/no-track_env_var.patch

This file was deleted.

12 changes: 6 additions & 6 deletions pkgs/development/tools/rust/rust-analyzer/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ 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 "s/cargoSha256 = \".*\"/cargoSha256 = \"\"/" \
sed -e "s#rev = \".*\"#rev = \"$rev\"#" \
-e "s#sha256 = \".*\"#sha256 = \"$sha256\"#" \
-e "s#cargoSha256 = \".*\"#cargoSha256 = \"\"#" \
--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\")")" -gt 0 ]]; then
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\"/" \
sed "s#cargoSha256 = \".*\"#cargoSha256 = \"$cargo_sha256\"#" \
--in-place ./default.nix

# Update vscode extension
Expand Down
5 changes: 3 additions & 2 deletions pkgs/development/tools/rust/rust-analyzer/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ lib.makeOverridable ({
unwrapped,
pname ? "rust-analyzer",
version ? unwrapped.version,
rustcSrc ? rustPlatform.rustcSrc,
# Use name from `RUST_SRC_PATH`
rustSrc ? rustPlatform.rustLibSrc,
}: runCommandNoCC "${pname}-${version}" {
inherit pname version;
inherit (unwrapped) src meta;
nativeBuildInputs = [ makeWrapper ];
} ''
mkdir -p $out/bin
makeWrapper ${unwrapped}/bin/rust-analyzer $out/bin/rust-analyzer \
--set-default RUST_SRC_PATH "${rustcSrc}"
--set-default RUST_SRC_PATH "${rustSrc}"
'')
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.4.0-dev",
"dependencies": {
"node-fetch": "^2.6.1",
"vscode-languageclient": "7.0.0-next.9",
"vscode-languageclient": "7.0.0-next.12",
"@rollup/plugin-commonjs": "^13.0.2",
"@rollup/plugin-node-resolve": "^8.4.0",
"@types/glob": "^7.1.3",
Expand Down