1{ lib, stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, menhir, menhirLib, yojson, ulex, pprint, fix, functory }:
2
3if lib.versionAtLeast ocaml.version "4.06"
4then throw "mezzo is not available for OCaml ${ocaml.version}"
5else
6
7let
8 check-ocaml-version = with lib; versionAtLeast (getVersion ocaml);
9in
10
11assert check-ocaml-version "4";
12
13stdenv.mkDerivation {
14
15 pname = "mezzo";
16 version = "0.0.m8";
17
18 src = fetchFromGitHub {
19 owner = "protz";
20 repo = "mezzo";
21 rev = "m8";
22 sha256 = "0yck5r6di0935s3iy2mm9538jkf77ssr789qb06ms7sivd7g3ip6";
23 };
24
25 buildInputs = [ ocaml findlib ocamlbuild yojson menhir menhirLib ulex pprint fix functory ];
26
27 # Sets warning 3 as non-fatal
28 prePatch = lib.optionalString (check-ocaml-version "4.02") ''
29 substituteInPlace myocamlbuild.pre.ml \
30 --replace '@1..3' '@1..2+3'
31 ''
32 # Compatibility with PPrint ≥ 20220103
33 + ''
34 substituteInPlace typing/Fact.ml --replace PPrintOCaml PPrint.OCaml
35 '';
36
37 createFindlibDestdir = true;
38
39 postInstall = ''
40 mkdir $out/bin
41 cp mezzo $out/bin/
42 '';
43
44 meta = with lib; {
45 homepage = "http://protz.github.io/mezzo/";
46 description = "A programming language in the ML tradition, which places strong emphasis on the control of aliasing and access to mutable memory";
47 license = licenses.gpl2;
48 platforms = ocaml.meta.platforms or [];
49 };
50}
51
52