2022-03-30 09:31:56 +00:00
|
|
|
{ lib, stdenv, ocaml, findlib, dune_1, dune_2, dune_3 }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
{ pname, version, nativeBuildInputs ? [], enableParallelBuilding ? true, ... }@args:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
let Dune =
|
2023-05-24 13:37:59 +00:00
|
|
|
let dune-version = args.duneVersion or "3"; in
|
2022-03-30 09:31:56 +00:00
|
|
|
{ "1" = dune_1; "2" = dune_2; "3" = dune_3; }."${dune-version}"
|
|
|
|
; in
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-06-24 18:47:55 +00:00
|
|
|
if args ? minimalOCamlVersion && lib.versionOlder ocaml.version args.minimalOCamlVersion
|
2020-04-24 23:36:52 +00:00
|
|
|
then throw "${pname}-${version} is not available for OCaml ${ocaml.version}"
|
|
|
|
else
|
|
|
|
|
|
|
|
stdenv.mkDerivation ({
|
|
|
|
|
2020-05-03 17:38:23 +00:00
|
|
|
inherit enableParallelBuilding;
|
2021-09-18 10:52:07 +00:00
|
|
|
dontAddStaticConfigureFlags = true;
|
|
|
|
configurePlatforms = [];
|
2020-05-03 17:38:23 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2020-05-03 17:38:23 +00:00
|
|
|
dune build -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
2020-05-03 17:38:23 +00:00
|
|
|
dune runtest -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2023-03-15 16:39:30 +00:00
|
|
|
dune install --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname} \
|
|
|
|
${if lib.versionAtLeast Dune.version "2.9"
|
2023-03-30 22:05:00 +00:00
|
|
|
then "--docdir $out/share/doc --mandir $out/share/man"
|
2023-03-15 16:39:30 +00:00
|
|
|
else ""}
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
} // (builtins.removeAttrs args [ "minimalOCamlVersion" "duneVersion" ]) // {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
name = "ocaml${ocaml.version}-${pname}-${version}";
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
nativeBuildInputs = [ ocaml Dune findlib ] ++ nativeBuildInputs;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
meta = (args.meta or {}) // { platforms = args.meta.platforms or ocaml.meta.platforms; };
|
|
|
|
|
|
|
|
})
|