1{
2 lib,
3 stdenv,
4 fetchurl,
5 curl,
6 tzdata,
7 autoPatchelfHook,
8 fixDarwinDylibNames,
9 libxml2,
10}:
11
12let
13 inherit (stdenv) hostPlatform;
14 OS = if hostPlatform.isDarwin then "osx" else hostPlatform.parsed.kernel.name;
15 ARCH =
16 if hostPlatform.isDarwin && hostPlatform.isAarch64 then "arm64" else hostPlatform.parsed.cpu.name;
17 version = "1.41.0";
18 hashes = {
19 # Get these from `nix store prefetch-file https://github.com/ldc-developers/ldc/releases/download/v1.19.0/ldc2-1.19.0-osx-x86_64.tar.xz` etc..
20 osx-x86_64 = "sha256-W8/0i2PFakXbqs2wxb3cjqa+htSgx7LHyDGOBH9yEYE=";
21 linux-x86_64 = "sha256-SkOUV/D+WeadAv1rV1Sfw8h60PVa2fueQlB7b44yfI8=";
22 linux-aarch64 = "sha256-HEuVChPVM3ntT1ZDZsJ+xW1iYeIWhogNcMdIaz6Me6g=";
23 osx-arm64 = "sha256-FXJnBC8QsEchBhkxSqcZtPC/iHYB6TscY0qh7LPFRuQ=";
24 };
25in
26stdenv.mkDerivation {
27 pname = "ldc-bootstrap";
28 inherit version;
29
30 src = fetchurl rec {
31 name = "ldc2-${version}-${OS}-${ARCH}.tar.xz";
32 url = "https://github.com/ldc-developers/ldc/releases/download/v${version}/${name}";
33 hash = hashes."${OS}-${ARCH}" or (throw "missing bootstrap hash for ${OS}-${ARCH}");
34 };
35
36 dontConfigure = true;
37 dontBuild = true;
38
39 nativeBuildInputs =
40 lib.optionals hostPlatform.isLinux [
41 autoPatchelfHook
42 ]
43 ++ lib.optional hostPlatform.isDarwin fixDarwinDylibNames;
44
45 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
46 libxml2
47 stdenv.cc.cc
48 ];
49
50 propagatedBuildInputs = [
51 curl
52 tzdata
53 ];
54
55 installPhase = ''
56 mkdir -p $out
57
58 mv bin etc import lib LICENSE README $out/
59 '';
60
61 meta = with lib; {
62 description = "LLVM-based D Compiler";
63 homepage = "https://github.com/ldc-developers/ldc";
64 # from https://github.com/ldc-developers/ldc/blob/master/LICENSE
65 license = with licenses; [
66 bsd3
67 boost
68 mit
69 ncsa
70 gpl2Plus
71 ];
72 maintainers = with maintainers; [ lionello ];
73 platforms = [
74 "x86_64-linux"
75 "x86_64-darwin"
76 "aarch64-linux"
77 "aarch64-darwin"
78 ];
79 };
80}