2021-05-24 20:08:04 +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-06-21 18:24:15 +00:00
|
|
|
# FIXME: Test doesn't pass under rustc 1.52.1 due to different escaping of `'` in string.
|
|
|
|
, doCheck ? false
|
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";
|
2021-08-09 20:02:25 +00:00
|
|
|
version = "2021-08-09";
|
|
|
|
cargoSha256 = "sha256-r01riAztIlwxRjvqQXofmqv5875nqQ0Qb9KALvKy4u8=";
|
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;
|
2021-08-09 20:02:25 +00:00
|
|
|
sha256 = "sha256-l9F/cznYHxBdnb3NerIXzOMrzRnxdka0vExzUtKkBfw=";
|
2020-01-18 19:34:16 +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
|
|
|
cargoBuildFlags = lib.optional useMimalloc "--features=mimalloc";
|
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-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; {
|
2020-01-18 19:34:16 +00:00
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|