···11+/* Topkg is a packager for distributing OCaml software. This derivation
22+provides facilities to describe derivations for OCaml libraries
33+using topkg.
44+The `buildPhase` and `installPhase` attributes can be reused directly
55+in many cases. When more fine-grained control on how to run the “topkg”
66+build system is required, the attribute `run` can be used.
77+*/
18{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, result, opam }:
29310if !stdenv.lib.versionAtLeast ocaml.version "4.01"
411then throw "topkg is not available for OCaml ${ocaml.version}"
512else
6131414+let
1515+/* This command allows to run the “topkg” build system.
1616+ * It is usually called with `build` or `test` as argument.
1717+ * Packages that use `topkg` may call this command as part of
1818+ * their `buildPhase` or `checkPhase`.
1919+*/
2020+ run = "ocaml -I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/ pkg/pkg.ml";
2121+in
2222+723stdenv.mkDerivation rec {
824 name = "ocaml${ocaml.version}-topkg-${version}";
925 version = "0.9.1";
···1329 sha256 = "1slrzbmyp81xhgsfwwqs2d6gxzvqx0gcp34rq00h5iblhcq7myx6";
1430 };
15311616- nativeBuildInputs = [ opam ];
1732 buildInputs = [ ocaml findlib ocamlbuild ];
1833 propagatedBuildInputs = [ result ];
19342035 unpackCmd = "tar xjf ${src}";
2121- buildPhase = "ocaml -I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/ pkg/pkg.ml build";
3636+ buildPhase = "${run} build";
2237 createFindlibDestdir = true;
2323- installPhase = "opam-installer -i --prefix=$out --libdir=$OCAMLFIND_DESTDIR";
3838+ installPhase = "${opam}/bin/opam-installer -i --prefix=$out --libdir=$OCAMLFIND_DESTDIR";
3939+4040+ passthru = { inherit run; };
24412542 meta = {
2643 homepage = http://erratique.ch/software/topkg;