1 { lib, stdenv, fetchurl, patchelf, gmp }:
3 dynamic-linker = stdenv.cc.bintools.dynamicLinker;
5 stdenv.mkDerivation rec {
9 src = if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl {
10 url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${pname}-${version}-1.amd64-linux.tgz";
11 sha256 = "0f4q575yfm5dpg4a2wsnqn4l2zrar96p6rlsk0dw10ggyfwvsjlf";
13 else if stdenv.hostPlatform.system == "x86_64-darwin" then (fetchurl {
14 url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${pname}-${version}-1.amd64-darwin.gmp-static.tgz";
15 sha256 = "1cw7yhw48qp12q0adwf8srpjzrgkp84kmlkqw3pz8vkxz4p9hbdv";
18 throw "Architecture not supported";
20 buildInputs = [ gmp ];
21 nativeBuildInputs = lib.optional stdenv.isLinux patchelf;
26 WITH_GMP_INC_DIR="${gmp.dev}/include" \
27 WITH_GMP_LIB_DIR="${gmp}/lib"
31 make install PREFIX=$out
34 postFixup = lib.optionalString stdenv.isLinux ''
35 patchelf --set-interpreter ${dynamic-linker} $out/lib/mlton/mlton-compile
36 patchelf --set-rpath ${gmp}/lib $out/lib/mlton/mlton-compile
38 for e in mllex mlnlffigen mlprof mlyacc; do
39 patchelf --set-interpreter ${dynamic-linker} $out/bin/$e
40 patchelf --set-rpath ${gmp}/lib $out/bin/$e
42 '' + lib.optionalString stdenv.isDarwin ''
43 install_name_tool -change \
44 /opt/local/lib/libgmp.10.dylib \
45 ${gmp}/lib/libgmp.10.dylib \
46 $out/lib/mlton/mlton-compile
48 for e in mllex mlnlffigen mlprof mlyacc; do
49 install_name_tool -change \
50 /opt/local/lib/libgmp.10.dylib \
51 ${gmp}/lib/libgmp.10.dylib \
56 meta = import ./meta.nix;