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 = [ autoPatchelfHook ]
22 ++ lib.optional hostPlatform.isDarwin fixDarwinDylibNames;
23 propagatedBuildInputs = [ curl tzdata ] ++ lib.optional hostPlatform.isLinux glibc;
24
25 installPhase = ''
26 mkdir -p $out
27
28 # try to copy model-specific binaries into bin first
29 mv ${OS}/bin${MODEL} $out/bin || true
30
31 mv src license.txt ${OS}/* $out/
32
33 # move man into place
34 mkdir -p $out/share
35 mv man $out/share/
36
37 # move docs into place
38 mkdir -p $out/share/doc
39 mv html/d $out/share/doc/
40
41 # fix paths in dmd.conf (one level less)
42 substituteInPlace $out/bin/dmd.conf --replace "/../../" "/../"
43 '';
44
45 meta = with lib; {
46 description = "Digital Mars D Compiler Package";
47 # As of 2.075 all sources and binaries use the boost license
48 license = licenses.boost;
49 maintainers = [ maintainers.lionello ];
50 homepage = "https://dlang.org/";
51 platforms = [ "x86_64-darwin" "i686-linux" "x86_64-linux" ];
52 };
53}