@@ -0,0 +1,54 @@
1+{stdenv, lib, fetchFromGitHub, dmd, curl}:
2+
3+stdenv.mkDerivation rec {
4+ name = "dtools-${version}";
5+ version = "2.075.1";
6+
7+ src = fetchFromGitHub {
8+ owner = "dlang";
9+ repo = "tools";
10+ rev = "v${version}";
11+ sha256 = "0lxn400s9las9hq6h9vj4mis2jr662k2yw0zcrvqcm1yg9pd245d";
12+ };
13+
14+ postPatch = ''
15+ substituteInPlace posix.mak \
16+ --replace "../dmd/generated/\$(OS)/release/\$(MODEL)/dmd" ${dmd.out}/bin/dmd
17+
18+ substituteInPlace posix.mak \
19+ --replace gcc $CC
20+ '';
21+
22+ nativeBuildInputs = [ dmd ];
23+ buildInputs = [ curl ];
24+
25+ buildPhase = ''
26+ make -f posix.mak DMD=${dmd.out}/bin/dmd INSTALL_DIR=$out
27+ '';
28+
29+ doCheck = true;
30+
31+ checkPhase = ''
32+ export BITS=${builtins.toString stdenv.hostPlatform.parsed.cpu.bits}
33+ export OSNAME=${if stdenv.hostPlatform.isDarwin then "osx" else stdenv.hostPlatform.parsed.kernel.name}
34+ ./generated/$OSNAME/$BITS/rdmd -main -unittest rdmd.d
35+ ${dmd.out}/bin/dmd rdmd_test.d
36+ ./rdmd_test
37+ '';
38+
39+ installPhase = ''
40+ mkdir -p $out/bin
41+ ${
42+ let bits = builtins.toString stdenv.hostPlatform.parsed.cpu.bits;
43+ osname = if stdenv.hostPlatform.isDarwin then "osx" else stdenv.hostPlatform.parsed.kernel.name; in
44+ "find $PWD/generated/${osname}/${bits} -perm /a+x -type f -exec cp {} $out/bin \\;"
45+ }
46+ '';
47+
48+ meta = {
49+ description = "Ancillary tools for the D programming language compiler";
50+ homepage = https://github.com/dlang/tools;
51+ license = lib.licenses.boost;
52+ platforms = stdenv.lib.platforms.unix;
53+ };
54+}