mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-22 21:18:28 +03:00
Merge pull request #150775 from oxalica/bump/rust-analyzer
rust-analyzer: 2021-11-29 -> 2021-12-13
This commit is contained in:
commit
fd2cd8235a
@ -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";
|
||||
|
@ -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<Vec<ast::Path>> {
|
||||
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<Vec<ast::Pat
|
||||
// only nodes that we can find are other TokenTrees, those are unexpected in this parse though
|
||||
None => 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()
|
@ -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
|
||||
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user