2021-06-04 09:07:49 +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";
|
2021-08-25 08:27:29 +00:00
|
|
|
version = "2021-08-23";
|
|
|
|
cargoSha256 = "sha256-FMOLYR8cyimAA71SlxcT370wpeNH4f8vwv+oAhUd8zc=";
|
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;
|
2021-08-25 08:27:29 +00:00
|
|
|
sha256 = "sha256-6Tbgy77Essi3Hyd5kdJ7JJbx7RuFZQWURfRrpScvPPQ=";
|
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";
|
|
|
|
|
|
|
|
cargoBuildFlags = lib.optional useMimalloc "--features=mimalloc";
|
2021-08-27 14:25:00 +00:00
|
|
|
cargoTestFlags = lib.optional useMimalloc "--features=mimalloc";
|
2021-04-12 18:23:04 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = lib.optional useMimalloc cmake;
|
|
|
|
|
|
|
|
buildInputs = lib.optionals stdenv.isDarwin [
|
|
|
|
CoreServices
|
|
|
|
libiconv
|
|
|
|
];
|
|
|
|
|
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; {
|
|
|
|
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 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|