2020-09-25 04:45:31 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, rustPlatform, darwin, cmake
|
|
|
|
, useMimalloc ? false
|
2020-04-24 23:36:52 +00:00
|
|
|
, doCheck ? true
|
|
|
|
|
|
|
|
# Version specific args
|
2020-09-25 04:45:31 +00:00
|
|
|
, rev, version, sha256, cargoSha256
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
rustPlatform.buildRustPackage {
|
|
|
|
pname = "rust-analyzer-unwrapped";
|
|
|
|
inherit version cargoSha256;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "rust-analyzer";
|
|
|
|
repo = "rust-analyzer";
|
|
|
|
inherit rev sha256;
|
|
|
|
};
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
# FIXME: Temporary fix for our rust 1.45.0 since rust-analyzer requires 1.46.0
|
|
|
|
cargoPatches = [
|
|
|
|
./downgrade-smol_str.patch
|
|
|
|
];
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
patches = [
|
|
|
|
# FIXME: Temporary fix for our rust 1.45.0 since rust-analyzer requires 1.46.0
|
|
|
|
./no-loop-in-const-fn.patch
|
|
|
|
./no-option-zip.patch
|
|
|
|
];
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
buildAndTestSubdir = "crates/rust-analyzer";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
cargoBuildFlags = lib.optional useMimalloc "--features=mimalloc";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
nativeBuildInputs = lib.optional useMimalloc cmake;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin
|
|
|
|
[ darwin.apple_sdk.frameworks.CoreServices ];
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
RUST_ANALYZER_REV = rev;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit doCheck;
|
2020-09-25 04:45:31 +00:00
|
|
|
preCheck = lib.optionalString doCheck ''
|
2020-04-24 23:36:52 +00:00
|
|
|
export RUST_SRC_PATH=${rustPlatform.rustcSrc}
|
|
|
|
'';
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
doInstallCheck = true;
|
2020-07-18 16:06:22 +00:00
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
versionOutput="$($out/bin/rust-analyzer --version)"
|
|
|
|
echo "'rust-analyzer --version' returns: $versionOutput"
|
|
|
|
[[ "$versionOutput" == "rust-analyzer ${rev}" ]]
|
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|