summary refs log tree commit diff
path: root/pkgs/development/ocaml-modules/janestreet/buildOcamlJane.nix
blob: 6e988c4479a56af0ceb6b707caa03fcfaf3392d9 (plain) (blame)
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
{ buildOcaml, opam, js_build_tools, ocaml_oasis_46, fetchurl } :

{ name, version ? "113.33.03", buildInputs ? [],
  hash ? "",
  minimumSupportedOcamlVersion ? "4.02", ...
}@args:

buildOcaml (args // {
  inherit name version minimumSupportedOcamlVersion;
  src = fetchurl {
    url = "https://github.com/janestreet/${name}/archive/${version}.tar.gz";
    sha256 = hash;
  };

  hasSharedObjects = true;

  buildInputs = [ ocaml_oasis_46 js_build_tools opam ] ++ buildInputs;

  dontAddPrefix = true;

  configurePhase = "./configure --prefix $out";

  buildPhase = "OCAML_TOPLEVEL_PATH=`ocamlfind query findlib`/.. make";

  installPhase = ''
    opam-installer -i --prefix $prefix --libdir `ocamlfind printconf destdir` --stubsdir `ocamlfind printconf destdir`/${name} ${name}.install
    if [ -d $out/lib/${name} ]
      then if [ "$(ls -A $out/lib/${name})" ]
        then mv $out/lib/${name}/* `ocamlfind printconf destdir`/${name}
      fi
      rmdir $out/lib/${name}
    fi
  '';

})