summaryrefslogtreecommitdiffhomepage
path: root/nix-overlays/dmd/binary.nix
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2024-04-24 12:11:50 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2024-04-24 12:11:50 -0400
commit7591439b407b39ecfc37b667bc3d54192aa4b9ef (patch)
treee95e3977686f54735fcd8707da815ead918e703d /nix-overlays/dmd/binary.nix
ldc-1.37.0 ... dub 1.36.0
Diffstat (limited to 'nix-overlays/dmd/binary.nix')
-rw-r--r--nix-overlays/dmd/binary.nix77
1 files changed, 77 insertions, 0 deletions
diff --git a/nix-overlays/dmd/binary.nix b/nix-overlays/dmd/binary.nix
new file mode 100644
index 0000000..3a5d6b7
--- /dev/null
+++ b/nix-overlays/dmd/binary.nix
@@ -0,0 +1,77 @@
+{ lib, stdenv, fetchurl, curl, tzdata, autoPatchelfHook, fixDarwinDylibNames, glibc
+, version, hashes }:
+
+let
+ inherit (stdenv) hostPlatform;
+ OS = if hostPlatform.isDarwin then "osx" else hostPlatform.parsed.kernel.name;
+ MODEL = toString hostPlatform.parsed.cpu.bits;
+in
+
+# On linux pargets like `pkgsLLVM.dmd` `cc` does not expose `libgcc`
+# and can't build `dmd`.
+assert hostPlatform.isLinux -> (stdenv.cc.cc ? libgcc);
+stdenv.mkDerivation {
+ pname = "dmd-bootstrap";
+ inherit version;
+
+ src = fetchurl rec {
+ name = "dmd.${version}.${OS}.tar.xz";
+ url = "http://downloads.dlang.org/releases/2.x/${version}/${name}";
+ sha256 = hashes.${OS} or (throw "missing bootstrap sha256 for OS ${OS}");
+ };
+
+ dontConfigure = true;
+ dontBuild = true;
+
+ nativeBuildInputs = lib.optionals hostPlatform.isLinux [
+ autoPatchelfHook
+ ] ++ lib.optionals hostPlatform.isDarwin [
+ fixDarwinDylibNames
+ ];
+ propagatedBuildInputs = [
+ curl
+ tzdata
+ ] ++ lib.optionals hostPlatform.isLinux [
+ glibc
+ stdenv.cc.cc.libgcc
+ ];
+
+ installPhase = ''
+ runHook preInstall
+
+ mkdir -p $out
+
+ # try to copy model-specific binaries into bin first
+ mv ${OS}/bin${MODEL} $out/bin || true
+
+ mv src license.txt ${OS}/* $out/
+
+ # move man into place
+ mkdir -p $out/share
+ mv man $out/share/
+
+ # move docs into place
+ mkdir -p $out/share/doc
+ mv html/d $out/share/doc/
+
+ # fix paths in dmd.conf (one level less)
+ substituteInPlace $out/bin/dmd.conf --replace "/../../" "/../"
+
+ runHook postInstall
+ '';
+
+ # Stripping on Darwin started to break libphobos2.a
+ # Undefined symbols for architecture x86_64:
+ # "_rt_envvars_enabled", referenced from:
+ # __D2rt6config16rt_envvarsOptionFNbNiAyaMDFNbNiQkZQnZQq in libphobos2.a(config_99a_6c3.o)
+ dontStrip = hostPlatform.isDarwin;
+
+ meta = with lib; {
+ description = "Digital Mars D Compiler Package";
+ # As of 2.075 all sources and binaries use the boost license
+ license = licenses.boost;
+ maintainers = [ maintainers.lionello ];
+ homepage = "https://dlang.org/";
+ platforms = [ "x86_64-darwin" "i686-linux" "x86_64-linux" ];
+ };
+}