diff --git a/pkgs/development/compilers/mlton/20241230-binary.nix b/pkgs/development/compilers/mlton/20241230-binary.nix new file mode 100644 index 000000000000..f73d1dfcbc75 --- /dev/null +++ b/pkgs/development/compilers/mlton/20241230-binary.nix @@ -0,0 +1,78 @@ +{ + lib, + stdenv, + fetchurl, + patchelf, + bash, + gmp, +}: +let + dynamic-linker = stdenv.cc.bintools.dynamicLinker; +in +stdenv.mkDerivation rec { + pname = "mlton"; + version = "20241230"; + + src = + if stdenv.hostPlatform.system == "x86_64-linux" then + (fetchurl { + url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${pname}-${version}-1.amd64-linux.ubuntu-24.04_glibc2.39.tgz"; + sha256 = "sha256-ldXnjHcWGu77LP9WL6vTC6FngzhxPFAUflAA+bpIFZM="; + }) + else if stdenv.hostPlatform.system == "x86_64-darwin" then + (fetchurl { + url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${pname}-${version}-1.amd64-darwin.macos-13_gmp-static.tgz"; + sha256 = "sha256-fW0hqjrWUcy+PIN8WHb1r4EYgfuwF9Zz3q7f2ZtxOi0="; + }) + else if stdenv.hostPlatform.system == "aarch64-darwin" then + (fetchurl { + url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${pname}-${version}-1.arm64-darwin.macos-15_gmp-static.tgz"; + sha256 = "sha256-xhFP2plFjP/mbLz1CNtlZzkm0Kx6twfD/Dmn79Vj908="; + }) + else + throw "Architecture not supported"; + + buildInputs = [ + bash + gmp + ]; + nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux patchelf; + strictDeps = true; + + buildPhase = '' + make update \ + CC="$(type -p cc)" \ + WITH_GMP_INC_DIR="${gmp.dev}/include" \ + WITH_GMP_LIB_DIR="${gmp}/lib" + ''; + + installPhase = '' + make install PREFIX=$out + ''; + + postFixup = + lib.optionalString stdenv.hostPlatform.isLinux '' + patchelf --set-interpreter ${dynamic-linker} $out/lib/mlton/mlton-compile + patchelf --set-rpath ${gmp}/lib $out/lib/mlton/mlton-compile + + for e in mllex mlnlffigen mlprof mlyacc; do + patchelf --set-interpreter ${dynamic-linker} $out/bin/$e + patchelf --set-rpath ${gmp}/lib $out/bin/$e + done + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + install_name_tool -change \ + /opt/local/lib/libgmp.10.dylib \ + ${gmp}/lib/libgmp.10.dylib \ + $out/lib/mlton/mlton-compile + + for e in mllex mlnlffigen mlprof mlyacc; do + install_name_tool -change \ + /opt/local/lib/libgmp.10.dylib \ + ${gmp}/lib/libgmp.10.dylib \ + $out/bin/$e + done + ''; + + meta = import ./meta.nix { inherit lib; }; +} diff --git a/pkgs/development/compilers/mlton/default.nix b/pkgs/development/compilers/mlton/default.nix index 91d70e431ff3..b97be3512183 100644 --- a/pkgs/development/compilers/mlton/default.nix +++ b/pkgs/development/compilers/mlton/default.nix @@ -21,8 +21,10 @@ rec { sha256 = "sha256-rqL8lnzVVR+5Hc7sWXK8dCXN92dU76qSoii3/4StODM="; }; + mlton20241230Binary = callPackage ./20241230-binary.nix { }; + mlton20241230 = callPackage ./from-git-source.nix { - mltonBootstrap = mlton20210117Binary; + mltonBootstrap = mlton20241230Binary; version = "20241230"; rev = "on-20241230-release"; sha256 = "sha256-gJUzav2xH8C4Vy5FuqN73Z6lPMSPQgJApF8LgsJXRWo="; @@ -31,7 +33,7 @@ rec { }; mltonHEAD = callPackage ./from-git-source.nix { - mltonBootstrap = mlton20210117Binary; + mltonBootstrap = mlton20241230Binary; version = "HEAD"; rev = "61baac7108fbd91413f0537b7a42d9a1023455f4"; sha256 = "sha256-nWR7ZaXfKxeXfZ9IHipAQ39ASVtva4BeDHP3Zq8mqPo=";