···1+/* Topkg is a packager for distributing OCaml software. This derivation
2+provides facilities to describe derivations for OCaml libraries
3+using topkg.
4+The `buildPhase` and `installPhase` attributes can be reused directly
5+in many cases. When more fine-grained control on how to run the “topkg”
6+build system is required, the attribute `run` can be used.
7+*/
8{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, result, opam }:
910if !stdenv.lib.versionAtLeast ocaml.version "4.01"
11then throw "topkg is not available for OCaml ${ocaml.version}"
12else
1314+let
15+/* This command allows to run the “topkg” build system.
16+ * It is usually called with `build` or `test` as argument.
17+ * Packages that use `topkg` may call this command as part of
18+ * their `buildPhase` or `checkPhase`.
19+*/
20+ run = "ocaml -I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/ pkg/pkg.ml";
21+in
22+23stdenv.mkDerivation rec {
24 name = "ocaml${ocaml.version}-topkg-${version}";
25 version = "0.9.1";
···29 sha256 = "1slrzbmyp81xhgsfwwqs2d6gxzvqx0gcp34rq00h5iblhcq7myx6";
30 };
31032 buildInputs = [ ocaml findlib ocamlbuild ];
33 propagatedBuildInputs = [ result ];
3435 unpackCmd = "tar xjf ${src}";
36+ buildPhase = "${run} build";
37 createFindlibDestdir = true;
38+ installPhase = "${opam}/bin/opam-installer -i --prefix=$out --libdir=$OCAMLFIND_DESTDIR";
39+40+ passthru = { inherit run; };
4142 meta = {
43 homepage = http://erratique.ch/software/topkg;