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