@@ -0,0 +1,33 @@
1+{ stdenv, fetchurl, ocaml, findlib, result, opam }:
2+
3+let ocaml-version = stdenv.lib.getVersion ocaml; in
4+
5+stdenv.mkDerivation rec {
6+ name = "ocaml${ocaml-version}-topkg-${version}";
7+ version = "0.7.8";
8+
9+ src = fetchurl {
10+ url = "http://erratique.ch/software/topkg/releases/topkg-${version}.tbz";
11+ sha256 = "029lbmabczpmcgkj53mc20vmpcn3f7rf7xms4xf0nywswfzsash6";
12+ };
13+
14+ nativeBuildInputs = [ opam ];
15+ buildInputs = [ ocaml findlib ];
16+ propagatedBuildInputs = [ result ];
17+
18+ unpackCmd = "tar xjf ${src}";
19+ buildPhase = "ocaml -I ${findlib}/lib/ocaml/${ocaml-version}/site-lib/ pkg/pkg.ml build";
20+ createFindlibDestdir = true;
21+ installPhase = ''
22+ opam-installer --script --prefix=$out topkg.install | sh
23+ mv $out/lib/topkg $out/lib/ocaml/${ocaml-version}/site-lib/
24+ '';
25+
26+ meta = {
27+ homepage = http://erratique.ch/software/topkg;
28+ license = stdenv.lib.licenses.isc;
29+ maintainers = [ stdenv.lib.maintainers.vbgl ];
30+ description = "A packager for distributing OCaml software";
31+ inherit (ocaml.meta) platforms;
32+ };
33+}