at 24.05-pre 2.0 kB view raw
1{ lib 2, stdenv 3, callPackage 4, fetchFromGitHub 5, rustPlatform 6, CoreServices 7, cmake 8, libiconv 9, useMimalloc ? false 10, doCheck ? true 11, nix-update-script 12}: 13 14rustPlatform.buildRustPackage rec { 15 pname = "rust-analyzer-unwrapped"; 16 version = "2023-11-13"; 17 cargoSha256 = "sha256-Nrq8si+myWLmhaJrvxK+Ki599A5VddNcCd5kQZWTnNs="; 18 19 src = fetchFromGitHub { 20 owner = "rust-lang"; 21 repo = "rust-analyzer"; 22 rev = version; 23 sha256 = "sha256-gjMqmlCvLVlptL35HHvALrOKrFyxjg5hryXbbpVyoeY="; 24 }; 25 26 cargoBuildFlags = [ "--bin" "rust-analyzer" "--bin" "rust-analyzer-proc-macro-srv" ]; 27 cargoTestFlags = [ "--package" "rust-analyzer" "--package" "proc-macro-srv-cli" ]; 28 29 # Code format check requires more dependencies but don't really matter for packaging. 30 # So just ignore it. 31 checkFlags = [ "--skip=tidy::check_code_formatting" ]; 32 33 nativeBuildInputs = lib.optional useMimalloc cmake; 34 35 buildInputs = lib.optionals stdenv.isDarwin [ 36 CoreServices 37 libiconv 38 ]; 39 40 buildFeatures = lib.optional useMimalloc "mimalloc"; 41 42 CFG_RELEASE = version; 43 44 inherit doCheck; 45 preCheck = lib.optionalString doCheck '' 46 export RUST_SRC_PATH=${rustPlatform.rustLibSrc} 47 ''; 48 49 doInstallCheck = true; 50 installCheckPhase = '' 51 runHook preInstallCheck 52 versionOutput="$($out/bin/rust-analyzer --version)" 53 echo "'rust-analyzer --version' returns: $versionOutput" 54 [[ "$versionOutput" == "rust-analyzer ${version}" ]] 55 runHook postInstallCheck 56 ''; 57 58 passthru = { 59 updateScript = nix-update-script { }; 60 # FIXME: Pass overrided `rust-analyzer` once `buildRustPackage` also implements #119942 61 tests.neovim-lsp = callPackage ./test-neovim-lsp.nix { }; 62 }; 63 64 meta = with lib; { 65 description = "A modular compiler frontend for the Rust language"; 66 homepage = "https://rust-analyzer.github.io"; 67 license = with licenses; [ mit asl20 ]; 68 maintainers = with maintainers; [ oxalica ]; 69 mainProgram = "rust-analyzer"; 70 }; 71}