depot/third_party/nixpkgs/pkgs/development/tools/rust/rust-analyzer/default.nix

59 lines
1.5 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchFromGitHub, rustPlatform, CoreServices, cmake
, libiconv
, useMimalloc ? false
, doCheck ? true
}:
let
rev = "2021-04-05";
in
rustPlatform.buildRustPackage {
pname = "rust-analyzer-unwrapped";
version = "unstable-${rev}";
cargoSha256 = "sha256-kDwdKa08E0h24lOOa7ALeNqHlMjMry/ru1qwCIyKmuE=";
src = fetchFromGitHub {
owner = "rust-analyzer";
repo = "rust-analyzer";
inherit rev;
sha256 = "sha256-ZDxy87F3uz8bTF1/2LIy5r4Nv/M3xe97F7mwJNEFcUs=";
};
buildAndTestSubdir = "crates/rust-analyzer";
cargoBuildFlags = lib.optional useMimalloc "--features=mimalloc";
nativeBuildInputs = lib.optional useMimalloc cmake;
buildInputs = lib.optionals stdenv.isDarwin [
CoreServices
libiconv
];
RUST_ANALYZER_REV = rev;
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"
[[ "$versionOutput" == "rust-analyzer ${rev}" ]]
runHook postInstallCheck
'';
passthru.updateScript = ./update.sh;
meta = with 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 ];
};
}