1{ lib, stdenv, fetchurl, curl, tzdata, autoPatchelfHook, fixDarwinDylibNames, libxml2
2, version, hashes }:
3
4let
5 inherit (stdenv) hostPlatform;
6 OS = if hostPlatform.isDarwin then "osx" else hostPlatform.parsed.kernel.name;
7 ARCH = if hostPlatform.isDarwin && hostPlatform.isAarch64 then "arm64" else hostPlatform.parsed.cpu.name;
8in stdenv.mkDerivation {
9 pname = "ldc-bootstrap";
10 inherit version;
11
12 src = fetchurl rec {
13 name = "ldc2-${version}-${OS}-${ARCH}.tar.xz";
14 url = "https://github.com/ldc-developers/ldc/releases/download/v${version}/${name}";
15 sha256 = hashes."${OS}-${ARCH}" or (throw "missing bootstrap sha256 for ${OS}-${ARCH}");
16 };
17
18 dontConfigure = true;
19 dontBuild = true;
20
21 nativeBuildInputs = lib.optionals hostPlatform.isLinux [
22 autoPatchelfHook
23 ] ++ lib.optional hostPlatform.isDarwin fixDarwinDylibNames;
24
25 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ libxml2 stdenv.cc.cc ];
26
27 propagatedBuildInputs = [ curl tzdata ];
28
29 installPhase = ''
30 mkdir -p $out
31
32 mv bin etc import lib LICENSE README $out/
33 '';
34
35 meta = with lib; {
36 description = "The LLVM-based D Compiler";
37 homepage = "https://github.com/ldc-developers/ldc";
38 # from https://github.com/ldc-developers/ldc/blob/master/LICENSE
39 license = with licenses; [ bsd3 boost mit ncsa gpl2Plus ];
40 maintainers = with maintainers; [ ThomasMader lionello ];
41 platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
42 };
43}