1{ lib, stdenv, fetchurl, curl, tzdata, autoPatchelfHook, fixDarwinDylibNames, glibc
2, version, hashes }:
3
4let
5 inherit (stdenv) hostPlatform;
6 OS = if hostPlatform.isDarwin then "osx" else hostPlatform.parsed.kernel.name;
7 MODEL = toString hostPlatform.parsed.cpu.bits;
8in stdenv.mkDerivation {
9 pname = "dmd-bootstrap";
10 inherit version;
11
12 src = fetchurl rec {
13 name = "dmd.${version}.${OS}.tar.xz";
14 url = "http://downloads.dlang.org/releases/2.x/${version}/${name}";
15 sha256 = hashes.${OS} or (throw "missing bootstrap sha256 for OS ${OS}");
16 };
17
18 dontConfigure = true;
19 dontBuild = true;
20
21 nativeBuildInputs = lib.optionals hostPlatform.isLinux [
22 autoPatchelfHook
23 ] ++ lib.optionals hostPlatform.isDarwin [
24 fixDarwinDylibNames
25 ];
26 propagatedBuildInputs = [
27 curl
28 tzdata
29 ] ++ lib.optionals hostPlatform.isLinux [
30 glibc
31 stdenv.cc.cc.libgcc
32 ];
33
34 installPhase = ''
35 runHook preInstall
36
37 mkdir -p $out
38
39 # try to copy model-specific binaries into bin first
40 mv ${OS}/bin${MODEL} $out/bin || true
41
42 mv src license.txt ${OS}/* $out/
43
44 # move man into place
45 mkdir -p $out/share
46 mv man $out/share/
47
48 # move docs into place
49 mkdir -p $out/share/doc
50 mv html/d $out/share/doc/
51
52 # fix paths in dmd.conf (one level less)
53 substituteInPlace $out/bin/dmd.conf --replace "/../../" "/../"
54
55 runHook postInstall
56 '';
57
58 # Stripping on Darwin started to break libphobos2.a
59 # Undefined symbols for architecture x86_64:
60 # "_rt_envvars_enabled", referenced from:
61 # __D2rt6config16rt_envvarsOptionFNbNiAyaMDFNbNiQkZQnZQq in libphobos2.a(config_99a_6c3.o)
62 dontStrip = hostPlatform.isDarwin;
63
64 meta = with lib; {
65 description = "Digital Mars D Compiler Package";
66 # As of 2.075 all sources and binaries use the boost license
67 license = licenses.boost;
68 maintainers = [ maintainers.lionello ];
69 homepage = "https://dlang.org/";
70 platforms = [ "x86_64-darwin" "i686-linux" "x86_64-linux" ];
71 };
72}