1{
2 lib,
3 stdenv,
4 fetchurl,
5 ocaml,
6 findlib,
7 ocamlbuild,
8 ounit,
9}:
10
11let
12 # ounit is only available for OCaml >= 4.08
13 doCheck = lib.versionAtLeast ocaml.version "4.08";
14in
15
16lib.throwIf (lib.versionAtLeast ocaml.version "5.0") "ocamlmod is not available for OCaml ≥ 5.0"
17
18 stdenv.mkDerivation
19 {
20 pname = "ocamlmod";
21 version = "0.0.9";
22
23 src = fetchurl {
24 url = "https://forge.ocamlcore.org/frs/download.php/1702/ocamlmod-0.0.9.tar.gz";
25 sha256 = "0cgp9qqrq7ayyhddrmqmq1affvfqcn722qiakjq4dkywvp67h4aa";
26 };
27
28 strictDeps = !doCheck;
29
30 nativeBuildInputs = [
31 ocaml
32 findlib
33 ocamlbuild
34 ];
35
36 configurePhase =
37 "ocaml setup.ml -configure --prefix $out" + lib.optionalString doCheck " --enable-tests";
38 buildPhase = "ocaml setup.ml -build";
39 installPhase = "ocaml setup.ml -install";
40
41 inherit doCheck;
42 nativeCheckInputs = [ ounit ];
43
44 checkPhase = "ocaml setup.ml -test";
45
46 dontStrip = true;
47
48 meta = {
49 homepage = "https://forge.ocamlcore.org/projects/ocamlmod/ocamlmod";
50 description = "Generate OCaml modules from source files";
51 platforms = ocaml.meta.platforms or [ ];
52 maintainers = with lib.maintainers; [
53 maggesi
54 ];
55 };
56 }