2024-06-30 08:12:46 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
ocaml,
|
|
|
|
findlib,
|
|
|
|
dune_1,
|
|
|
|
dune_2,
|
|
|
|
dune_3,
|
|
|
|
}:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
{
|
|
|
|
pname,
|
|
|
|
version,
|
|
|
|
nativeBuildInputs ? [ ],
|
|
|
|
enableParallelBuilding ? true,
|
|
|
|
...
|
|
|
|
}@args:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
let
|
|
|
|
Dune =
|
|
|
|
let
|
|
|
|
dune-version = args.duneVersion or "3";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
"1" = dune_1;
|
|
|
|
"2" = dune_2;
|
|
|
|
"3" = dune_3;
|
|
|
|
}
|
|
|
|
."${dune-version}";
|
|
|
|
in
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
if
|
|
|
|
(args ? minimumOCamlVersion && lib.versionOlder ocaml.version args.minimumOCamlVersion)
|
|
|
|
|| (args ? minimalOCamlVersion && lib.versionOlder ocaml.version args.minimalOCamlVersion)
|
|
|
|
then
|
|
|
|
throw "${pname}-${version} is not available for OCaml ${ocaml.version}"
|
2024-05-02 00:46:19 +00:00
|
|
|
else
|
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
stdenv.mkDerivation (
|
|
|
|
{
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
inherit enableParallelBuilding;
|
|
|
|
dontAddStaticConfigureFlags = true;
|
|
|
|
configurePlatforms = [ ];
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
dune build -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
dune runtest -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
dune install --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname} \
|
|
|
|
${
|
|
|
|
if lib.versionAtLeast Dune.version "2.9" then
|
|
|
|
"--docdir $out/share/doc --mandir $out/share/man"
|
|
|
|
else
|
|
|
|
""
|
|
|
|
}
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
strictDeps = true;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
}
|
|
|
|
// (builtins.removeAttrs args [
|
|
|
|
"minimalOCamlVersion"
|
|
|
|
"duneVersion"
|
|
|
|
])
|
|
|
|
// {
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
name = "ocaml${ocaml.version}-${pname}-${version}";
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
ocaml
|
|
|
|
Dune
|
|
|
|
findlib
|
|
|
|
] ++ nativeBuildInputs;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
meta = (args.meta or { }) // {
|
|
|
|
platforms = args.meta.platforms or ocaml.meta.platforms;
|
|
|
|
};
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
}
|
|
|
|
)
|