summary refs log tree commit diff
path: root/pkgs/development/compilers/reason/default.nix
blob: 7bd4750551f332466198b9302c2cf61d80b556ac (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ stdenv, makeWrapper, buildOcaml, fetchFromGitHub,
  ocaml, opam, topkg, menhir, merlin_extend, ppx_tools_versioned, utop }:

let 
  version = "1.13.4";
  src = fetchFromGitHub {
    owner = "facebook";
    repo = "reason";
    rev = version;
    sha256 = "03r2ciikgwaq1dkzgzc8n7h7y0q95ajh6n9bb2n5bpgfhwkr1wqi";
  };
  meta = with stdenv.lib; {
    homepage = https://facebook.github.io/reason/;
    description = "Facebook's friendly syntax to OCaml";
    license = licenses.bsd3;
    maintainers = [ maintainers.volth ];
  };

  reason-parser = buildOcaml {
    name = "reason-parser";
    inherit version src meta;
    sourceRoot = "reason-${version}-src/reason-parser";

    minimumSupportedOcamlVersion = "4.02";

    propagatedBuildInputs = [ menhir merlin_extend ppx_tools_versioned ];
    buildInputs = [ opam topkg ];

    createFindlibDestdir = true;

    inherit (topkg) installPhase;
  };
in
buildOcaml {
  name = "reason";
  inherit version src meta;

  buildInputs = [ makeWrapper opam topkg reason-parser utop ];

  buildFlags = [ "build" ]; # do not "make tests" before reason lib is installed

  createFindlibDestdir = true;

  postPatch = ''
    substituteInPlace src/reasonbuild.ml --replace "refmt --print binary" "$out/bin/refmt --print binary"
  '';

  installPhase = ''
    ${topkg.installPhase}

    wrapProgram $out/bin/reup \
      --prefix PATH : "${opam}/bin"
    wrapProgram $out/bin/rtop \
      --prefix PATH : "${utop}/bin" \
      --set OCAMLPATH $out/lib/ocaml/${ocaml.version}/site-lib:$OCAMLPATH
  '';
}