1 { lib, stdenv, ocaml, findlib, dune_1, dune_2, dune_3 }:
3 { pname, version, nativeBuildInputs ? [], enableParallelBuilding ? true, ... }@args:
6 let dune-version = args.duneVersion or "3"; in
7 { "1" = dune_1; "2" = dune_2; "3" = dune_3; }."${dune-version}"
10 if (args ? minimumOCamlVersion && lib.versionOlder ocaml.version args.minimumOCamlVersion) ||
11 (args ? minimalOCamlVersion && lib.versionOlder ocaml.version args.minimalOCamlVersion)
12 then throw "${pname}-${version} is not available for OCaml ${ocaml.version}"
15 stdenv.mkDerivation ({
17 inherit enableParallelBuilding;
18 dontAddStaticConfigureFlags = true;
19 configurePlatforms = [];
23 dune build -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
28 dune runtest -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
33 dune install --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname} \
34 ${if lib.versionAtLeast Dune.version "2.9"
35 then "--docdir $out/share/doc --mandir $out/share/man"
42 } // (builtins.removeAttrs args [ "minimalOCamlVersion" "duneVersion" ]) // {
44 name = "ocaml${ocaml.version}-${pname}-${version}";
46 nativeBuildInputs = [ ocaml Dune findlib ] ++ nativeBuildInputs;
48 meta = (args.meta or {}) // { platforms = args.meta.platforms or ocaml.meta.platforms; };