2021-10-25 12:26:59 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2022-05-17 17:27:46 +00:00
|
|
|
, callPackage
|
2021-10-25 12:26:59 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, rustPlatform
|
|
|
|
, CoreServices
|
|
|
|
, cmake
|
2021-03-16 16:27:10 +00:00
|
|
|
, libiconv
|
2020-09-17 18:33:12 +00:00
|
|
|
, useMimalloc ? false
|
2021-08-24 20:56:02 +00:00
|
|
|
, doCheck ? true
|
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";
|
2023-02-12 05:39:38 +00:00
|
|
|
version = "2023-02-06";
|
|
|
|
cargoSha256 = "sha256-TYMK905P5FvDxWo3ntDjNsgYxz+tBQptxWh5p6OKE64=";
|
2020-01-18 19:34:16 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2022-05-07 02:20:43 +00:00
|
|
|
owner = "rust-lang";
|
2020-01-18 19:34:16 +00:00
|
|
|
repo = "rust-analyzer";
|
2021-04-12 07:06:42 +00:00
|
|
|
rev = version;
|
2023-02-12 05:39:38 +00:00
|
|
|
sha256 = "sha256-apIUZwMwZkWqd7anSGcI1g+2rYfd5GoxIpFFabUFYBU=";
|
2020-01-18 19:34:16 +00:00
|
|
|
};
|
|
|
|
|
2022-12-05 23:43:48 +00:00
|
|
|
auditable = true; # TODO: remove when this is the default
|
|
|
|
|
2022-08-23 08:23:36 +00:00
|
|
|
cargoBuildFlags = [ "--bin" "rust-analyzer" "--bin" "rust-analyzer-proc-macro-srv" ];
|
|
|
|
cargoTestFlags = [ "--package" "rust-analyzer" "--package" "proc-macro-srv-cli" ];
|
2021-09-21 15:18:55 +00:00
|
|
|
|
2022-08-23 08:23:36 +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"];
|
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-11-16 00:49:31 +00:00
|
|
|
buildFeatures = lib.optional useMimalloc "mimalloc";
|
|
|
|
|
2022-06-17 07:37:11 +00:00
|
|
|
CFG_RELEASE = 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
|
|
|
|
'';
|
|
|
|
|
2022-05-17 17:27:46 +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-02-22 12:00:24 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2021-11-30 20:54:05 +00:00
|
|
|
description = "A modular compiler frontend for the Rust language";
|
|
|
|
homepage = "https://rust-analyzer.github.io";
|
2020-01-18 19:34:16 +00:00
|
|
|
license = with licenses; [ mit asl20 ];
|
|
|
|
maintainers = with maintainers; [ oxalica ];
|
2022-05-05 00:46:39 +00:00
|
|
|
mainProgram = "rust-analyzer";
|
2020-01-18 19:34:16 +00:00
|
|
|
};
|
|
|
|
}
|