about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/rust/rust-analyzer/generic.nix
blob: ae6ad80cdd9aefc92a923b856b75c08d4599d15e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ lib, stdenv, fetchFromGitHub, rustPlatform, darwin
, useJemalloc ? false
, doCheck ? true

# Version specific args
, rev, version, sha256, cargoSha256 }:

rustPlatform.buildRustPackage {
  pname = "rust-analyzer-unwrapped";
  inherit version cargoSha256;

  src = fetchFromGitHub {
    owner = "rust-analyzer";
    repo = "rust-analyzer";
    inherit rev sha256;
  };

  buildAndTestSubdir = "crates/rust-analyzer";

  cargoBuildFlags = lib.optional useJemalloc "--features=jemalloc";

  nativeBuildInputs = lib.optionals doCheck [ rustPlatform.rustcSrc ];

  buildInputs = lib.optionals stdenv.hostPlatform.isDarwin
    [ darwin.apple_sdk.frameworks.CoreServices ];

  inherit doCheck;
  # Skip tests running `rustup` for `cargo fmt`.
  preCheck = ''
    fakeRustup=$(mktemp -d)
    ln -s $(command -v true) $fakeRustup/rustup
    export PATH=$PATH''${PATH:+:}$fakeRustup
    export RUST_SRC_PATH=${rustPlatform.rustcSrc}
  '';

  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 ];
    platforms = platforms.all;
  };
}