Merge pull request #77752 from oxalica/rust-analyzer

rust-analyzer: init at unstable-2020-03-09
This commit is contained in:
Jörg Thalheim 2020-04-14 10:19:59 +01:00 committed by GitHub
commit 418b24b133
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 3651 additions and 2060 deletions

View file

@ -5720,6 +5720,16 @@
githubId = 108072;
name = "Slawomir Gonet";
};
oxalica = {
email = "oxalicc@pm.me";
github = "oxalica";
githubId = 14816024;
name = "oxalica";
keys = [{
longkeyid = "rsa4096/0xCED392DE0C483D00";
fingerprint = "5CB0 E9E5 D5D5 71F5 7F54 0FEA CED3 92DE 0C48 3D00";
}];
};
oxij = {
email = "oxij@oxij.org";
github = "oxij";

View file

@ -142,6 +142,7 @@
, "react-native-cli"
, "react-tools"
, "reveal.js"
, { "rust-analyzer-build-deps": "../../misc/vscode-extensions/rust-analyzer/build-deps" }
, "s3http"
, "semver"
, "serve"

File diff suppressed because it is too large Load diff

View file

@ -1372,22 +1372,22 @@ let
sha1 = "de3e5f8961c88c787ee1368df849ac4413eca8d7";
};
};
"mkdirp-0.5.4" = {
"mkdirp-0.5.5" = {
name = "mkdirp";
packageName = "mkdirp";
version = "0.5.4";
version = "0.5.5";
src = fetchurl {
url = "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.4.tgz";
sha512 = "iG9AK/dJLtJ0XNgTuDbSyNS3zECqDlAhnQW4CsNxBG3LQJBbHmRX1egw39DmtOdCAqY+dKXV+sgPgilNWUKMVw==";
url = "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz";
sha512 = "NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==";
};
};
"mkdirp-1.0.3" = {
"mkdirp-1.0.4" = {
name = "mkdirp";
packageName = "mkdirp";
version = "1.0.3";
version = "1.0.4";
src = fetchurl {
url = "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.3.tgz";
sha512 = "6uCP4Qc0sWsgMLy1EOqqS/3rjDHOEnsStVr/4vtAIK2Y5i2kA7lFFejYrpIyiN9w0pYf4ckeCYT9f1r1P9KX5g==";
url = "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz";
sha512 = "vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==";
};
};
"ms-2.0.0" = {
@ -1426,13 +1426,13 @@ let
sha1 = "abcc6cbd3ec2ed2a729ff6e7c1fa8f01784a8574";
};
};
"needle-2.4.0" = {
"needle-2.4.1" = {
name = "needle";
packageName = "needle";
version = "2.4.0";
version = "2.4.1";
src = fetchurl {
url = "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz";
sha512 = "4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg==";
url = "https://registry.npmjs.org/needle/-/needle-2.4.1.tgz";
sha512 = "x/gi6ijr4B7fwl6WYL9FwlCvRQKGlUNvnceho8wxkwXqN8jvVmmmATTmZPRRG7b/yC1eode26C2HO9jl78Du9g==";
};
};
"nijs-0.0.25" = {
@ -1759,13 +1759,13 @@ let
sha1 = "212d5bfe1318306a420f6402b8e26ff39647a849";
};
};
"psl-1.7.0" = {
"psl-1.8.0" = {
name = "psl";
packageName = "psl";
version = "1.7.0";
version = "1.8.0";
src = fetchurl {
url = "https://registry.npmjs.org/psl/-/psl-1.7.0.tgz";
sha512 = "5NsSEDv8zY70ScRnOTn7bK7eanl2MvFrOrS/R6x+dBt5g1ghnj9Zv90kO8GwT8gxcu2ANyFprnFYB85IogIJOQ==";
url = "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz";
sha512 = "RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==";
};
};
"punycode-2.1.1" = {
@ -2011,13 +2011,13 @@ let
sha512 = "JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==";
};
};
"signal-exit-3.0.2" = {
"signal-exit-3.0.3" = {
name = "signal-exit";
packageName = "signal-exit";
version = "3.0.2";
version = "3.0.3";
src = fetchurl {
url = "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz";
sha1 = "b5fdc08f1287ea1178628e415e25132b73646c6d";
url = "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz";
sha512 = "VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==";
};
};
"slasp-0.0.4" = {
@ -2857,7 +2857,7 @@ in
sources."minimist-1.2.5"
sources."minipass-3.1.1"
sources."minizlib-2.1.0"
sources."mkdirp-0.5.4"
sources."mkdirp-0.5.5"
sources."ncp-0.4.2"
sources."nijs-0.0.25"
sources."nopt-3.0.6"
@ -2896,7 +2896,7 @@ in
sources."performance-now-2.1.0"
sources."process-nextick-args-2.0.1"
sources."proto-list-1.2.4"
sources."psl-1.7.0"
sources."psl-1.8.0"
sources."punycode-2.1.1"
sources."qs-6.5.2"
(sources."readable-stream-2.3.7" // {
@ -2912,7 +2912,7 @@ in
sources."safer-buffer-2.1.2"
sources."semver-7.1.3"
sources."set-blocking-2.0.0"
sources."signal-exit-3.0.2"
sources."signal-exit-3.0.3"
sources."slasp-0.0.4"
sources."slide-1.1.6"
sources."spdx-correct-3.1.0"
@ -2930,7 +2930,7 @@ in
sources."strip-ansi-3.0.1"
(sources."tar-6.0.1" // {
dependencies = [
sources."mkdirp-1.0.3"
sources."mkdirp-1.0.4"
];
})
sources."temp-0.9.1"
@ -3028,7 +3028,7 @@ in
sources."minimist-1.2.5"
sources."minipass-2.9.0"
sources."minizlib-1.3.3"
sources."mkdirp-0.5.4"
sources."mkdirp-0.5.5"
sources."nopt-4.0.3"
sources."npmlog-4.1.2"
sources."number-is-nan-1.0.1"
@ -3041,7 +3041,7 @@ in
sources."path-is-absolute-1.0.1"
sources."performance-now-2.1.0"
sources."process-nextick-args-2.0.1"
sources."psl-1.7.0"
sources."psl-1.8.0"
sources."punycode-2.1.1"
sources."qs-6.5.2"
sources."readable-stream-2.3.7"
@ -3051,7 +3051,7 @@ in
sources."safer-buffer-2.1.2"
sources."semver-5.7.1"
sources."set-blocking-2.0.0"
sources."signal-exit-3.0.2"
sources."signal-exit-3.0.3"
sources."sshpk-1.16.1"
sources."string-width-1.0.2"
sources."string_decoder-1.1.1"
@ -3137,9 +3137,9 @@ in
sources."minimist-1.2.5"
sources."minipass-2.9.0"
sources."minizlib-1.3.3"
sources."mkdirp-0.5.4"
sources."mkdirp-0.5.5"
sources."ms-2.1.2"
sources."needle-2.4.0"
sources."needle-2.4.1"
sources."nopt-4.0.3"
sources."npm-bundled-1.1.1"
sources."npm-normalize-package-bin-1.0.1"
@ -3161,7 +3161,7 @@ in
sources."sax-1.2.4"
sources."semver-5.7.1"
sources."set-blocking-2.0.0"
sources."signal-exit-3.0.2"
sources."signal-exit-3.0.3"
sources."string-width-1.0.2"
sources."string_decoder-1.1.1"
sources."strip-ansi-3.0.1"

View file

@ -634,22 +634,22 @@ let
sha1 = "de3e5f8961c88c787ee1368df849ac4413eca8d7";
};
};
"mkdirp-0.5.4" = {
"mkdirp-0.5.5" = {
name = "mkdirp";
packageName = "mkdirp";
version = "0.5.4";
version = "0.5.5";
src = fetchurl {
url = "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.4.tgz";
sha512 = "iG9AK/dJLtJ0XNgTuDbSyNS3zECqDlAhnQW4CsNxBG3LQJBbHmRX1egw39DmtOdCAqY+dKXV+sgPgilNWUKMVw==";
url = "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz";
sha512 = "NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==";
};
};
"mkdirp-1.0.3" = {
"mkdirp-1.0.4" = {
name = "mkdirp";
packageName = "mkdirp";
version = "1.0.3";
version = "1.0.4";
src = fetchurl {
url = "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.3.tgz";
sha512 = "6uCP4Qc0sWsgMLy1EOqqS/3rjDHOEnsStVr/4vtAIK2Y5i2kA7lFFejYrpIyiN9w0pYf4ckeCYT9f1r1P9KX5g==";
url = "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz";
sha512 = "vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==";
};
};
"ncp-0.4.2" = {
@ -850,13 +850,13 @@ let
sha1 = "212d5bfe1318306a420f6402b8e26ff39647a849";
};
};
"psl-1.7.0" = {
"psl-1.8.0" = {
name = "psl";
packageName = "psl";
version = "1.7.0";
version = "1.8.0";
src = fetchurl {
url = "https://registry.npmjs.org/psl/-/psl-1.7.0.tgz";
sha512 = "5NsSEDv8zY70ScRnOTn7bK7eanl2MvFrOrS/R6x+dBt5g1ghnj9Zv90kO8GwT8gxcu2ANyFprnFYB85IogIJOQ==";
url = "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz";
sha512 = "RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==";
};
};
"punycode-2.1.1" = {
@ -994,13 +994,13 @@ let
sha1 = "045f9782d011ae9a6803ddd382b24392b3d890f7";
};
};
"signal-exit-3.0.2" = {
"signal-exit-3.0.3" = {
name = "signal-exit";
packageName = "signal-exit";
version = "3.0.2";
version = "3.0.3";
src = fetchurl {
url = "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz";
sha1 = "b5fdc08f1287ea1178628e415e25132b73646c6d";
url = "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz";
sha512 = "VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==";
};
};
"slasp-0.0.4" = {
@ -1345,7 +1345,7 @@ in
sources."minimist-1.2.5"
sources."minipass-3.1.1"
sources."minizlib-2.1.0"
sources."mkdirp-0.5.4"
sources."mkdirp-0.5.5"
sources."ncp-0.4.2"
sources."nijs-0.0.25"
sources."nopt-3.0.6"
@ -1384,7 +1384,7 @@ in
sources."performance-now-2.1.0"
sources."process-nextick-args-2.0.1"
sources."proto-list-1.2.4"
sources."psl-1.7.0"
sources."psl-1.8.0"
sources."punycode-2.1.1"
sources."qs-6.5.2"
(sources."readable-stream-2.3.7" // {
@ -1400,7 +1400,7 @@ in
sources."safer-buffer-2.1.2"
sources."semver-7.1.3"
sources."set-blocking-2.0.0"
sources."signal-exit-3.0.2"
sources."signal-exit-3.0.3"
sources."slasp-0.0.4"
sources."slide-1.1.6"
sources."spdx-correct-3.1.0"
@ -1418,7 +1418,7 @@ in
sources."strip-ansi-3.0.1"
(sources."tar-6.0.1" // {
dependencies = [
sources."mkdirp-1.0.3"
sources."mkdirp-1.0.4"
];
})
sources."temp-0.9.1"

View file

@ -0,0 +1,14 @@
{ pkgs, callPackage }:
{
rust-analyzer-unwrapped = callPackage ./generic.nix rec {
rev = "2020-04-06";
version = "unstable-${rev}";
sha256 = "0cm12707rq88w9yd4kkh26pnaqfvif6yyshk42pfi9vyv4ljfpcv";
cargoSha256 = "0q1qwji407pmklwb27z2jwyrvwyn8zkmrwm4nbcgk53ci4p6a17k";
};
rust-analyzer = callPackage ./wrapper.nix {} {
unwrapped = pkgs.rust-analyzer-unwrapped;
};
}

View file

@ -0,0 +1,45 @@
{ lib, stdenv, fetchFromGitHub, rustPlatform, darwin
, useJemalloc ? false
, doCheck ? true
# Version specific args
, rev, version, sha256, cargoSha256 }:
rustPlatform.buildRustPackage {
pname = "rust-analyzer-unwrapped";
inherit version cargoSha256;
src = fetchFromGitHub {
owner = "rust-analyzer";
repo = "rust-analyzer";
inherit rev sha256;
};
preBuild = "pushd crates/rust-analyzer";
# Do not checking other crates in checkPhase.
preInstall = "popd";
cargoBuildFlags = lib.optional useJemalloc "--features=jemalloc";
nativeBuildInputs = lib.optionals doCheck [ rustPlatform.rustcSrc ];
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin
[ darwin.apple_sdk.frameworks.CoreServices ];
inherit doCheck;
# Skip tests running `rustup` for `cargo fmt`.
preCheck = ''
fakeRustup=$(mktemp -d)
ln -s $(command -v true) $fakeRustup/rustup
export PATH=$PATH''${PATH:+:}$fakeRustup
export RUST_SRC_PATH=${rustPlatform.rustcSrc}
'';
meta = with stdenv.lib; {
description = "An experimental modular compiler frontend for the Rust language";
homepage = "https://github.com/rust-analyzer/rust-analyzer";
license = with licenses; [ mit asl20 ];
maintainers = with maintainers; [ oxalica ];
platforms = platforms.all;
};
}

View file

@ -0,0 +1,61 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq nix-prefetch
set -euo pipefail
cd "$(dirname "$0")"
owner=rust-analyzer
repo=rust-analyzer
nixpkgs=../../../../..
# Update lsp
rev=$(
curl -s "https://api.github.com/repos/$owner/$repo/releases" |
jq 'map(select(.prerelease | not)) | .[0].tag_name' --raw-output
)
old_rev=$(sed -nE 's/.*\brev = "(.*)".*/\1/p' ./default.nix)
if grep -q 'cargoSha256 = ""' ./default.nix; then
old_rev='broken'
fi
if [[ "$rev" == "$old_rev" ]]; then
echo "Up to date: $rev"
exit
fi
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 = \"\"/" \
--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
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
build_deps="../../../../misc/vscode-extensions/rust-analyzer/build-deps"
# We need devDependencies to build vsix.
jq '{ name, version, dependencies: (.dependencies + .devDependencies) }' "$node_src/package.json" \
>"$build_deps/package.json"
# FIXME: Lock the version of @type/vscode, the latest one (1.43.0) will cause build failure.
vscode_lock_ver="$(jq '.dependencies."@types/vscode".version' --raw-output "$node_src/package-lock.json")"
jq '.dependencies."@types/vscode" = "'$vscode_lock_ver'"' "$build_deps/package.json" >"$build_deps/package.json.new"
mv "$build_deps"/package.json{.new,}
pushd "../../../node-packages"
./generate.sh
popd

View file

@ -0,0 +1,16 @@
{ lib, rustPlatform, runCommandNoCC, makeWrapper }:
lib.makeOverridable ({
unwrapped,
pname ? "rust-analyzer",
version ? unwrapped.version,
rustcSrc ? rustPlatform.rustcSrc,
}: 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}"
'')

View file

@ -140,6 +140,8 @@ in
};
};
matklad.rust-analyzer = callPackage ./rust-analyzer {};
scala-lang.scala = buildVscodeMarketplaceExtension {
mktplcRef = {
name = "scala";

View file

@ -0,0 +1,22 @@
{
"name": "rust-analyzer",
"version": "0.4.0-dev",
"dependencies": {
"jsonc-parser": "^2.2.1",
"node-fetch": "^2.6.0",
"vscode-languageclient": "6.1.3",
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@types/node": "^12.12.34",
"@types/node-fetch": "^2.5.5",
"@types/vscode": "1.43.0",
"@typescript-eslint/eslint-plugin": "^2.26.0",
"@typescript-eslint/parser": "^2.26.0",
"eslint": "^6.8.0",
"rollup": "^2.3.2",
"tslib": "^1.11.1",
"typescript": "^3.8.3",
"typescript-formatter": "^7.2.2",
"vsce": "^1.75.0"
}
}

View file

@ -0,0 +1,50 @@
# Update script: pkgs/development/tools/rust/rust-analyzer/update.sh
{ lib, stdenv, vscode-utils, jq, rust-analyzer, nodePackages_10_x
, setDefaultServerPath ? true
}:
let
pname = "rust-analyzer";
publisher = "matklad";
# Follow the unstable version of rust-analyzer, since the extension is not stable yet.
inherit (rust-analyzer) version;
build-deps = nodePackages_10_x."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";
outputs = [ "vsix" "out" ];
postInstall = ''
npm run package
mkdir $vsix
cp ${pname}.vsix $vsix/${pname}.zip
'';
};
in vscode-utils.buildVscodeExtension {
inherit version vsix;
name = "${pname}-${version}";
src = "${vsix}/${pname}.zip";
vscodeExtUniqueId = "${publisher}.${pname}";
nativeBuildInputs = lib.optional setDefaultServerPath jq;
postFixup = lib.optionalString setDefaultServerPath ''
package_json="$out/${publisher}.${pname}/package.json"
jq '.contributes.configuration.properties."rust-analyzer.serverPath".default = $s' \
--arg s "${rust-analyzer}/bin/rust-analyzer" \
$package_json >$package_json.new
mv $package_json.new $package_json
'';
meta = with lib; {
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 ];
platforms = platforms.all;
};
}

View file

@ -9032,6 +9032,8 @@ in
rustracerd = callPackage ../development/tools/rust/racerd {
inherit (darwin.apple_sdk.frameworks) Security;
};
inherit (callPackage ../development/tools/rust/rust-analyzer { })
rust-analyzer-unwrapped rust-analyzer;
rust-bindgen = callPackage ../development/tools/rust/bindgen { };
rust-cbindgen = callPackage ../development/tools/rust/cbindgen {
inherit (darwin.apple_sdk.frameworks) Security;