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
|
2023-03-08 16:32:21 +00:00
|
|
|
, nix-update-script
|
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";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "2023-07-10";
|
|
|
|
cargoSha256 = "sha256-vC1LwbSnz8TNkmt23XIEZEzOViLJgn+J5e98MYWG+BU=";
|
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;
|
2023-07-15 17:15:38 +00:00
|
|
|
sha256 = "sha256-LPU6TxxzZd3FlAL+W6oo4g0WA/+6G2JccC93W4ED8yA=";
|
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.
|
2023-03-08 16:32:21 +00:00
|
|
|
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 = {
|
2023-03-08 16:32:21 +00:00
|
|
|
updateScript = nix-update-script { };
|
2022-06-16 17:23:12 +00:00
|
|
|
# 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
|
|
|
};
|
|
|
|
}
|