2021-10-25 12:26:59 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, rustPlatform
|
|
|
|
, CoreServices
|
|
|
|
, cmake
|
2021-03-16 16:27:10 +00:00
|
|
|
, libiconv
|
2020-09-17 18:33:12 +00:00
|
|
|
, useMimalloc ? false
|
2021-08-24 20:56:02 +00:00
|
|
|
, doCheck ? true
|
2020-09-17 18:33:12 +00:00
|
|
|
}:
|
2020-01-18 19:34:16 +00:00
|
|
|
|
2021-04-12 07:06:42 +00:00
|
|
|
rustPlatform.buildRustPackage rec {
|
2020-01-18 19:34:16 +00:00
|
|
|
pname = "rust-analyzer-unwrapped";
|
2022-04-11 12:58:12 +00:00
|
|
|
version = "2022-04-11";
|
|
|
|
cargoSha256 = "sha256-pc8S+5g67vN9170ABiHGe1t4Go0F63UiOeLd71USYCI=";
|
2020-01-18 19:34:16 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "rust-analyzer";
|
|
|
|
repo = "rust-analyzer";
|
2021-04-12 07:06:42 +00:00
|
|
|
rev = version;
|
2022-04-11 12:58:12 +00:00
|
|
|
sha256 = "sha256-miMIrDawSS1zXh6EuX03x5ACM2NTabksssSyutSNpjY=";
|
2020-01-18 19:34:16 +00:00
|
|
|
};
|
|
|
|
|
2021-08-24 20:56:02 +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-10-25 12:26:59 +00:00
|
|
|
];
|
2021-09-21 15:18:55 +00:00
|
|
|
|
2020-05-12 23:28:24 +00:00
|
|
|
buildAndTestSubdir = "crates/rust-analyzer";
|
2020-01-18 19:34:16 +00:00
|
|
|
|
2020-09-17 18:33:12 +00:00
|
|
|
nativeBuildInputs = lib.optional useMimalloc cmake;
|
2020-01-18 19:34:16 +00:00
|
|
|
|
2021-03-16 16:27:10 +00:00
|
|
|
buildInputs = lib.optionals stdenv.isDarwin [
|
|
|
|
CoreServices
|
|
|
|
libiconv
|
|
|
|
];
|
2020-01-18 19:34:16 +00:00
|
|
|
|
2021-11-16 00:49:31 +00:00
|
|
|
buildFeatures = lib.optional useMimalloc "mimalloc";
|
|
|
|
|
2021-04-12 07:06:42 +00:00
|
|
|
RUST_ANALYZER_REV = version;
|
2020-06-23 14:30:37 +00:00
|
|
|
|
2020-01-18 19:34:16 +00:00
|
|
|
inherit doCheck;
|
2020-09-17 18:33:12 +00:00
|
|
|
preCheck = lib.optionalString doCheck ''
|
2020-11-06 16:31:25 +00:00
|
|
|
export RUST_SRC_PATH=${rustPlatform.rustLibSrc}
|
2020-01-18 19:34:16 +00:00
|
|
|
'';
|
|
|
|
|
2020-09-17 18:33:12 +00:00
|
|
|
doInstallCheck = true;
|
2020-06-23 14:30:37 +00:00
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
versionOutput="$($out/bin/rust-analyzer --version)"
|
|
|
|
echo "'rust-analyzer --version' returns: $versionOutput"
|
2021-04-12 07:06:42 +00:00
|
|
|
[[ "$versionOutput" == "rust-analyzer ${version}" ]]
|
2020-06-23 14:30:37 +00:00
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
2021-02-22 12:00:24 +00:00
|
|
|
passthru.updateScript = ./update.sh;
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2021-11-30 20:54:05 +00:00
|
|
|
description = "A modular compiler frontend for the Rust language";
|
|
|
|
homepage = "https://rust-analyzer.github.io";
|
2020-01-18 19:34:16 +00:00
|
|
|
license = with licenses; [ mit asl20 ];
|
|
|
|
maintainers = with maintainers; [ oxalica ];
|
|
|
|
};
|
|
|
|
}
|