mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-29 18:33:00 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
61 lines
1.9 KiB
Nix
61 lines
1.9 KiB
Nix
{ lib, stdenv, fetchurl, patchelf, gmp }:
|
|
let
|
|
dynamic-linker = stdenv.cc.bintools.dynamicLinker;
|
|
in
|
|
stdenv.mkDerivation rec {
|
|
pname = "mlton";
|
|
version = "20210117";
|
|
|
|
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-glibc2.31.tgz.tgz";
|
|
sha256 = "0f4q575yfm5dpg4a2wsnqn4l2zrar96p6rlsk0dw10ggyfwvsjlf";
|
|
})
|
|
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-19.6.gmp-static.tgz";
|
|
sha256 = "1cw7yhw48qp12q0adwf8srpjzrgkp84kmlkqw3pz8vkxz4p9hbdv";
|
|
})
|
|
else
|
|
throw "Architecture not supported";
|
|
|
|
buildInputs = [ gmp ];
|
|
nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux patchelf;
|
|
|
|
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;
|
|
}
|