about summary refs log tree commit diff
path: root/pkgs/development/compilers/smlnj
diff options
context:
space:
mode:
authorSimon Chatterjee <code@chatts.net>2021-06-26 14:52:53 +0100
committerSimon Chatterjee <code@chatts.net>2021-06-28 10:50:53 +0100
commit9fdc5e10eea0b7f36d7712ae64a943787a807e00 (patch)
tree82a7462aba57a2cf1b14279324d3fe65bf0aa8f8 /pkgs/development/compilers/smlnj
parent867c0f85406e5f07192d0d3efeed0260f34fe74a (diff)
smlnj: fix x86_64-darwin build
Diffstat (limited to 'pkgs/development/compilers/smlnj')
-rw-r--r--pkgs/development/compilers/smlnj/default.nix14
1 files changed, 8 insertions, 6 deletions
diff --git a/pkgs/development/compilers/smlnj/default.nix b/pkgs/development/compilers/smlnj/default.nix
index 3e987e8ccdafc..d6d50f0303f6e 100644
--- a/pkgs/development/compilers/smlnj/default.nix
+++ b/pkgs/development/compilers/smlnj/default.nix
@@ -1,11 +1,9 @@
-{ lib, stdenv, fetchurl }:
+{ lib, stdenv, fetchurl, Libsystem }:
 let
   version = "110.95";
   baseurl = "http://smlnj.cs.uchicago.edu/dist/working/${version}";
 
-  isArch64 = stdenv.system == "x86_64-linux";
-
-  arch = if isArch64
+  arch = if stdenv.is64bit
     then "64"
     else "32";
 
@@ -14,7 +12,7 @@ let
   boot64 = { url = "${baseurl}/boot.amd64-unix.tgz";
              sha256 = "1zn96a83kb6bn6228yfjsvb58m2qxw9k4j3qz0p9c8za479w4ch6"; };
 
-  bootBinary = if isArch64
+  bootBinary = if stdenv.is64bit
                then boot64
                else boot32;
 
@@ -53,6 +51,10 @@ in stdenv.mkDerivation {
     sed -i '/PATH=/d' config/_arch-n-opsys base/runtime/config/gen-posix-names.sh
     echo SRCARCHIVEURL="file:/$TMP" > config/srcarchiveurl
     patch --verbose config/_heap2exec ${./heap2exec.diff}
+  '' + lib.optionalString stdenv.isDarwin ''
+    # Locate standard headers like <unistd.h>
+    substituteInPlace base/runtime/config/gen-posix-names.sh \
+      --replace "\$SDK_PATH/usr" "${Libsystem}"
   '';
 
   unpackPhase = ''
@@ -83,7 +85,7 @@ in stdenv.mkDerivation {
     description = "Standard ML of New Jersey, a compiler";
     homepage    = "http://smlnj.org";
     license     = licenses.bsd3;
-    platforms   = [ "x86_64-linux" "i686-linux" ];
+    platforms   = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ];
     maintainers = with maintainers; [ thoughtpolice ];
   };
 }