2021-12-06 16:07:01 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, rustPlatform
|
|
|
|
, CoreServices
|
|
|
|
, cmake
|
2021-04-12 18:23:04 +00:00
|
|
|
, libiconv
|
|
|
|
, useMimalloc ? false
|
2021-08-27 14:25:00 +00:00
|
|
|
, doCheck ? true
|
2021-04-12 18:23:04 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-13 19:44:15 +00:00
|
|
|
rustPlatform.buildRustPackage rec {
|
2021-04-12 18:23:04 +00:00
|
|
|
pname = "rust-analyzer-unwrapped";
|
2022-02-10 20:34:41 +00:00
|
|
|
version = "2022-01-31";
|
|
|
|
cargoSha256 = "sha256-BWCLzyCcLWwmh7Os7NjN2o89KD+VB0EHyZfTyYoYM08=";
|
2021-04-12 18:23:04 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "rust-analyzer";
|
|
|
|
repo = "rust-analyzer";
|
2021-04-13 19:44:15 +00:00
|
|
|
rev = version;
|
2022-02-10 20:34:41 +00:00
|
|
|
sha256 = "sha256-6+d/x7ZIyvkPLdn7ziXuPyKfxt/7z5PCWs7B960DFqk=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-08-27 14:25:00 +00:00
|
|
|
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
|
|
|
|
];
|
|
|
|
|
2021-04-12 18:23:04 +00:00
|
|
|
buildAndTestSubdir = "crates/rust-analyzer";
|
|
|
|
|
|
|
|
nativeBuildInputs = lib.optional useMimalloc cmake;
|
|
|
|
|
|
|
|
buildInputs = lib.optionals stdenv.isDarwin [
|
|
|
|
CoreServices
|
|
|
|
libiconv
|
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
buildFeatures = lib.optional useMimalloc "mimalloc";
|
|
|
|
|
2021-04-13 19:44:15 +00:00
|
|
|
RUST_ANALYZER_REV = version;
|
2021-04-12 18:23:04 +00:00
|
|
|
|
|
|
|
inherit doCheck;
|
|
|
|
preCheck = lib.optionalString doCheck ''
|
|
|
|
export RUST_SRC_PATH=${rustPlatform.rustLibSrc}
|
|
|
|
'';
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
versionOutput="$($out/bin/rust-analyzer --version)"
|
|
|
|
echo "'rust-analyzer --version' returns: $versionOutput"
|
2021-04-13 19:44:15 +00:00
|
|
|
[[ "$versionOutput" == "rust-analyzer ${version}" ]]
|
2021-04-12 18:23:04 +00:00
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.updateScript = ./update.sh;
|
|
|
|
|
|
|
|
meta = with lib; {
|
2021-12-06 16:07:01 +00:00
|
|
|
description = "A modular compiler frontend for the Rust language";
|
|
|
|
homepage = "https://rust-analyzer.github.io";
|
2021-04-12 18:23:04 +00:00
|
|
|
license = with licenses; [ mit asl20 ];
|
|
|
|
maintainers = with maintainers; [ oxalica ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|