2021-12-06 16:07:01 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2022-06-16 17:23:12 +00:00
|
|
|
, callPackage
|
2021-12-06 16:07:01 +00:00
|
|
|
, 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-10-06 18:32:54 +00:00
|
|
|
version = "2022-10-03";
|
|
|
|
cargoSha256 = "sha256-G6eCAlcsyRIuq0uOwosLO4ZrSAQvwDi36bkARjDQXSA=";
|
2021-04-12 18:23:04 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2022-05-18 14:49:53 +00:00
|
|
|
owner = "rust-lang";
|
2021-04-12 18:23:04 +00:00
|
|
|
repo = "rust-analyzer";
|
2021-04-13 19:44:15 +00:00
|
|
|
rev = version;
|
2022-10-06 18:32:54 +00:00
|
|
|
sha256 = "sha256-mVf9fjQbtYbrVvQSaJOCwArWIvXHrXqVVUhP0x9ZcVY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
cargoBuildFlags = [ "--bin" "rust-analyzer" "--bin" "rust-analyzer-proc-macro-srv" ];
|
|
|
|
cargoTestFlags = [ "--package" "rust-analyzer" "--package" "proc-macro-srv-cli" ];
|
2021-08-27 14:25:00 +00:00
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
# Code format check requires more dependencies but don't really matter for packaging.
|
|
|
|
# So just ignore it.
|
|
|
|
checkFlags = ["--skip=tidy::check_code_formatting"];
|
2021-04-12 18:23:04 +00:00
|
|
|
|
|
|
|
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";
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
CFG_RELEASE = 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
|
|
|
|
'';
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
# FIXME: Pass overrided `rust-analyzer` once `buildRustPackage` also implements #119942
|
|
|
|
tests.neovim-lsp = callPackage ./test-neovim-lsp.nix { };
|
|
|
|
};
|
2021-04-12 18:23:04 +00:00
|
|
|
|
|
|
|
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 ];
|
2022-05-18 14:49:53 +00:00
|
|
|
mainProgram = "rust-analyzer";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|