-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
68 lines (68 loc) · 1.74 KB
/
default.nix
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{ pkgs
, lib
, darwin
, fetchFromGitHub
, libiconv
, makeRustPlatform
, stdenv
, ...
}:
let
inherit (builtins) fromJSON isAttrs listToAttrs map readFile throw;
inherit (lib) findFirst hasPrefix optionals;
in
rec {
versions = fromJSON (readFile ./data/versions.json);
findVersionFor = rust:
findFirst
(ver: hasPrefix rust ver.rust)
(throw "Rust version ${rust} does not match any release")
versions;
make =
{ pname ? "rust-analyzer"
, version
, sha256 ? ""
, outputHashes ? { }
, cargo ? pkgs.cargo
, rustc ? pkgs.rustc
, override ? (_: { })
}:
let
rustPlatform =
makeRustPlatform { inherit cargo rustc; };
ver =
if isAttrs version && version ? "rust"
then (findVersionFor version.rust).rust_analyzer
else version;
drv = rec {
inherit pname;
version = ver;
src = fetchFromGitHub {
owner = "rust-lang";
repo = "rust-analyzer";
rev = version;
inherit sha256;
};
cargoLock = {
inherit outputHashes;
lockFile = "${src}/Cargo.lock";
};
buildInputs =
optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreServices
libiconv
];
cargoBuildFlags = [ "-p" "rust-analyzer" ];
doCheck = false;
CARGO_INCREMENTAL = 0;
RUST_ANALYZER_REV = version;
meta = {
description = "A modular compiler frontend for the Rust language";
homepage = "https://rust-analyzer.github.io";
license = with lib.licenses; [ mit asl20 ];
mainProgram = "rust-analyzer";
};
};
in
rustPlatform.buildRustPackage (drv // override drv);
}