summaryrefslogtreecommitdiff
path: root/pkgs/development/compilers/mlton/from-git-source.nix
blob: 954d64c3bbefa53cf6e21617e0389fc6502238f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
  lib,
  fetchgit,
  gmp,
  mltonBootstrap,
  url ? "https://github.com/mlton/mlton",
  rev,
  hash,
  stdenv,
  version,
  which,
  doCheck ? true,
}:

stdenv.mkDerivation {
  pname = "mlton";
  inherit version doCheck;

  src = fetchgit {
    inherit url rev hash;
  };

  nativeBuildInputs = [
    which
    mltonBootstrap
  ];

  buildInputs = [ gmp ];

  strictDeps = true;

  # build fails otherwise
  enableParallelBuilding = false;

  preBuild = ''
    find . -type f | grep -v -e '\.tgz''$' | xargs sed -i "s@/usr/bin/env bash@$(type -p bash)@"
    sed -i "s|/tmp|$TMPDIR|" bin/regression

    makeFlagsArray=(
      MLTON_VERSION="${version} ${rev}"
      CC="$(type -p cc)"
      PREFIX="$out"
      WITH_GMP_INC_DIR="${gmp.dev}/include"
      WITH_GMP_LIB_DIR="${gmp}/lib"
      )
  '';

  meta = import ./meta.nix { inherit lib; };
}