summary refs log tree commit diff
path: root/pkgs/development/ocaml-modules
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/ocaml-modules')
-rw-r--r--pkgs/development/ocaml-modules/alcotest/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/asn1-combinators/default.nix15
-rw-r--r--pkgs/development/ocaml-modules/astring/default.nix13
-rw-r--r--pkgs/development/ocaml-modules/bos/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/cmdliner/default.nix15
-rw-r--r--pkgs/development/ocaml-modules/cow/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/cpuid/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/decompress/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/fmt/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/fpath/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/functoria/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/integers/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/jsonm/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/logs/default.nix11
-rw-r--r--pkgs/development/ocaml-modules/mtime/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/nocrypto/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/notty/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/ocb-stubblr/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/octavius/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/otfm/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/otr/default.nix23
-rw-r--r--pkgs/development/ocaml-modules/ppx_deriving_yojson/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/ptime/default.nix8
-rw-r--r--pkgs/development/ocaml-modules/react/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/rresult/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/topkg/default.nix23
-rw-r--r--pkgs/development/ocaml-modules/tsdl/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/uucd/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/uucp/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/uuidm/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/uunf/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/uuseg/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/uutf/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/vg/default.nix6
-rw-r--r--pkgs/development/ocaml-modules/xmlm/default.nix13
35 files changed, 101 insertions, 156 deletions
diff --git a/pkgs/development/ocaml-modules/alcotest/default.nix b/pkgs/development/ocaml-modules/alcotest/default.nix
index 90ee8d905a6..80e34ecd06a 100644
--- a/pkgs/development/ocaml-modules/alcotest/default.nix
+++ b/pkgs/development/ocaml-modules/alcotest/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchzip, ocaml, findlib, ocamlbuild, topkg, opam, jbuilder
+{ stdenv, fetchzip, ocaml, findlib, ocamlbuild, topkg, jbuilder
 , cmdliner, astring, fmt, result
 }:
 
@@ -12,7 +12,7 @@ let param =
   } else {
     version = "0.7.2";
     sha256 = "1qgsz2zz5ky6s5pf3j3shc4fjc36rqnjflk8x0wl1fcpvvkr52md";
-    buildInputs = [ ocamlbuild opam topkg ];
+    buildInputs = [ ocamlbuild topkg ];
     inherit (topkg) buildPhase installPhase;
   };
 in
diff --git a/pkgs/development/ocaml-modules/asn1-combinators/default.nix b/pkgs/development/ocaml-modules/asn1-combinators/default.nix
index feeb94a5c46..65a310c9cf0 100644
--- a/pkgs/development/ocaml-modules/asn1-combinators/default.nix
+++ b/pkgs/development/ocaml-modules/asn1-combinators/default.nix
@@ -1,6 +1,4 @@
-{ stdenv, buildOcaml, fetchFromGitHub, ocaml, findlib, cstruct, zarith, ounit, result, topkg, opam }:
-
-let ocamlFlags = "-I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/"; in
+{ stdenv, buildOcaml, fetchFromGitHub, ocaml, findlib, cstruct, zarith, ounit, result, topkg }:
 
 buildOcaml rec {
   name = "asn1-combinators";
@@ -15,20 +13,17 @@ buildOcaml rec {
     sha256 = "0hpn049i46sdnv2i6m7r6m6ch0jz8argybh71wykbvcqdby08zxj";
   };
 
-  buildInputs = [ ocaml findlib ounit topkg opam ];
+  buildInputs = [ ocaml findlib ounit topkg ];
   propagatedBuildInputs = [ result cstruct zarith ];
 
   createFindlibDestdir = true;
 
-  buildPhase = "ocaml ${ocamlFlags} pkg/pkg.ml build --tests true";
+  buildPhase = "${topkg.run} build --tests true";
 
-  installPhase = ''
-    opam-installer --script --prefix=$out | sh
-    ln -s $out/lib/asn1-combinators $out/lib/ocaml/${ocaml.version}/site-lib
-  '';
+  inherit (topkg) installPhase;
 
   doCheck = true;
-  checkPhase = "ocaml ${ocamlFlags} pkg/pkg.ml test";
+  checkPhase = "${topkg.run} test";
 
   meta = {
     homepage = https://github.com/mirleft/ocaml-asn1-combinators;
diff --git a/pkgs/development/ocaml-modules/astring/default.nix b/pkgs/development/ocaml-modules/astring/default.nix
index d172b0f7463..97c59d8581f 100644
--- a/pkgs/development/ocaml-modules/astring/default.nix
+++ b/pkgs/development/ocaml-modules/astring/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, buildOcaml, ocaml, findlib, ocamlbuild, topkg, opam}:
+{ stdenv, fetchurl, buildOcaml, ocaml, findlib, ocamlbuild, topkg }:
 
 buildOcaml rec {
   version = "0.8.3";
@@ -11,16 +11,9 @@ buildOcaml rec {
 
   unpackCmd = "tar -xf $curSrc";
 
-  buildInputs = [ ocaml findlib ocamlbuild topkg opam ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg ];
 
-  buildPhase = ''
-    ocaml -I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/ pkg/pkg.ml build
-  '';
-
-  installPhase = ''
-    opam-installer --script --prefix=$out astring.install | sh
-    ln -s $out/lib/astring $out/lib/ocaml/${ocaml.version}/site-lib/
-  '';
+  inherit (topkg) buildPhase installPhase;
 
   meta = {
     homepage = http://erratique.ch/software/astring;
diff --git a/pkgs/development/ocaml-modules/bos/default.nix b/pkgs/development/ocaml-modules/bos/default.nix
index f8590de2b15..3cb9b405d5a 100644
--- a/pkgs/development/ocaml-modules/bos/default.nix
+++ b/pkgs/development/ocaml-modules/bos/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg
 , astring, fmt, fpath, logs, rresult
 }:
 
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
 
 	unpackCmd = "tar xjf $src";
 
-	buildInputs = [ ocaml findlib ocamlbuild opam topkg ];
+	buildInputs = [ ocaml findlib ocamlbuild topkg ];
 	propagatedBuildInputs = [ astring fmt fpath logs rresult ];
 
 	inherit (topkg) buildPhase installPhase;
diff --git a/pkgs/development/ocaml-modules/cmdliner/default.nix b/pkgs/development/ocaml-modules/cmdliner/default.nix
index 2e2abe897e0..4b055a130fd 100644
--- a/pkgs/development/ocaml-modules/cmdliner/default.nix
+++ b/pkgs/development/ocaml-modules/cmdliner/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg, result }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, result }:
 
 let
   pname = "cmdliner";
@@ -17,20 +17,11 @@ stdenv.mkDerivation rec {
 
   unpackCmd = "tar xjf $src";
 
-  nativeBuildInputs = [ ocamlbuild opam topkg ];
+  nativeBuildInputs = [ ocamlbuild topkg ];
   buildInputs = [ ocaml findlib ];
   propagatedBuildInputs = [ result ];
 
-  createFindlibDestdir = true;
-
-  buildPhase = ''
-    ocaml -I ${findlib}/lib/ocaml/${ocaml.version}/site-lib pkg/pkg.ml build
-  '';
-
-  installPhase = ''
-    opam-installer --script --prefix=$out | sh
-    ln -s $out/lib/${pname} $out/lib/ocaml/${ocaml.version}/site-lib/
-  '';
+  inherit (topkg) buildPhase installPhase;
 
   meta = with stdenv.lib; {
     homepage = http://erratique.ch/software/cmdliner;
diff --git a/pkgs/development/ocaml-modules/cow/default.nix b/pkgs/development/ocaml-modules/cow/default.nix
index eaf07818aeb..4832f5c39af 100644
--- a/pkgs/development/ocaml-modules/cow/default.nix
+++ b/pkgs/development/ocaml-modules/cow/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchFromGitHub, ocaml, findlib
-, ocamlbuild, topkg, opam
+, ocamlbuild, topkg
 , uri, xmlm, omd, ezjsonm }:
 
 stdenv.mkDerivation rec {
@@ -13,9 +13,7 @@ stdenv.mkDerivation rec {
     sha256 = "0snhabg7rfrrcq2ksr3qghiawd61cw3y4kp6rl7vs87j4cnk3kr2";
   };
 
-  createFindlibDestdir = true;
-
-  buildInputs = [ ocaml opam ocamlbuild findlib topkg ];
+  buildInputs = [ ocaml ocamlbuild findlib topkg ];
   propagatedBuildInputs = [ xmlm uri ezjsonm omd ];
 
   inherit (topkg) buildPhase installPhase;
diff --git a/pkgs/development/ocaml-modules/cpuid/default.nix b/pkgs/development/ocaml-modules/cpuid/default.nix
index 1bdf70e86c5..37400856f1a 100644
--- a/pkgs/development/ocaml-modules/cpuid/default.nix
+++ b/pkgs/development/ocaml-modules/cpuid/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg, ocb-stubblr }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, ocb-stubblr }:
 
 stdenv.mkDerivation {
   name = "ocaml${ocaml.version}-cpuid-0.1.0";
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
 
   unpackCmd = "tar xjf $src";
 
-  buildInputs = [ ocaml findlib ocamlbuild opam topkg ocb-stubblr ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg ocb-stubblr ];
 
   inherit (topkg) buildPhase installPhase;
 
diff --git a/pkgs/development/ocaml-modules/decompress/default.nix b/pkgs/development/ocaml-modules/decompress/default.nix
index 389a136aae6..70ec7fd34ae 100644
--- a/pkgs/development/ocaml-modules/decompress/default.nix
+++ b/pkgs/development/ocaml-modules/decompress/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, topkg, opam
+{ stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, topkg
 }:
 
 if !stdenv.lib.versionAtLeast ocaml.version "4.03"
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
 		sha256 = "0hfs5zrvimzvjwdg57vrxx9bb7irvlm07dk2yv3s5qhj30zimd08";
 	};
 
-	buildInputs = [ ocaml findlib ocamlbuild topkg opam ];
+	buildInputs = [ ocaml findlib ocamlbuild topkg ];
 
 	inherit (topkg) buildPhase installPhase;
 
diff --git a/pkgs/development/ocaml-modules/fmt/default.nix b/pkgs/development/ocaml-modules/fmt/default.nix
index 0d6ab72fade..2e7996f55d9 100644
--- a/pkgs/development/ocaml-modules/fmt/default.nix
+++ b/pkgs/development/ocaml-modules/fmt/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg, cmdliner, result, uchar }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, cmdliner, result, uchar }:
 
 stdenv.mkDerivation {
   name = "ocaml${ocaml.version}-fmt-0.8.4";
@@ -10,13 +10,11 @@ stdenv.mkDerivation {
 
   unpackCmd = "tar xjf $src";
 
-  buildInputs = [ ocaml findlib ocamlbuild opam topkg cmdliner ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg cmdliner ];
   propagatedBuildInputs = [ result uchar ];
 
   inherit (topkg) buildPhase installPhase;
 
-  createFindlibDestdir = true;
-
   meta = {
     homepage = http://erratique.ch/software/fmt;
     license = stdenv.lib.licenses.isc;
diff --git a/pkgs/development/ocaml-modules/fpath/default.nix b/pkgs/development/ocaml-modules/fpath/default.nix
index c5382ddd265..f812ab1d48c 100644
--- a/pkgs/development/ocaml-modules/fpath/default.nix
+++ b/pkgs/development/ocaml-modules/fpath/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg, astring }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, astring }:
 
 stdenv.mkDerivation {
   name = "ocaml${ocaml.version}-fpath-0.7.2";
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
 
   unpackCmd = "tar xjf $src";
 
-  buildInputs = [ ocaml findlib ocamlbuild opam topkg ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg ];
 
   propagatedBuildInputs = [ astring ];
 
diff --git a/pkgs/development/ocaml-modules/functoria/default.nix b/pkgs/development/ocaml-modules/functoria/default.nix
index 2d8c00c7238..150d8db16a0 100644
--- a/pkgs/development/ocaml-modules/functoria/default.nix
+++ b/pkgs/development/ocaml-modules/functoria/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg
 , bos, cmdliner, ocamlgraph
 }:
 
@@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
 
 	unpackCmd = "tar xjf $src";
 
-	buildInputs = [ ocaml findlib ocamlbuild opam topkg ];
+	buildInputs = [ ocaml findlib ocamlbuild topkg ];
 	propagatedBuildInputs = [ bos cmdliner ocamlgraph ];
 
 	inherit (topkg) buildPhase installPhase;
diff --git a/pkgs/development/ocaml-modules/integers/default.nix b/pkgs/development/ocaml-modules/integers/default.nix
index e76c3aadc03..f7d22baf3e9 100644
--- a/pkgs/development/ocaml-modules/integers/default.nix
+++ b/pkgs/development/ocaml-modules/integers/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, opam }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg }:
 
 stdenv.mkDerivation {
 	name = "ocaml${ocaml.version}-integers-0.2.2";
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
 
 	unpackCmd = "tar xjf $src";
 
-	buildInputs = [ ocaml findlib ocamlbuild topkg opam ];
+	buildInputs = [ ocaml findlib ocamlbuild topkg ];
 
 	inherit (topkg) buildPhase installPhase;
 
diff --git a/pkgs/development/ocaml-modules/jsonm/default.nix b/pkgs/development/ocaml-modules/jsonm/default.nix
index 2bdaf655648..0599a5f19fe 100644
--- a/pkgs/development/ocaml-modules/jsonm/default.nix
+++ b/pkgs/development/ocaml-modules/jsonm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, opam, uutf }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, uutf }:
 
 let version = "1.0.1"; in
 
@@ -10,13 +10,11 @@ stdenv.mkDerivation {
     sha256 = "1176dcmxb11fnw49b7yysvkjh0kpzx4s48lmdn5psq9vshp5c29w";
   };
 
-  buildInputs = [ ocaml findlib ocamlbuild topkg opam ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg ];
   propagatedBuildInputs = [ uutf ];
 
   unpackCmd = "tar xjf $src";
 
-  createFindlibDestdir = true;
-
   inherit (topkg) buildPhase installPhase;
 
   meta = {
diff --git a/pkgs/development/ocaml-modules/logs/default.nix b/pkgs/development/ocaml-modules/logs/default.nix
index ab0b6c8579b..aead4b4756f 100644
--- a/pkgs/development/ocaml-modules/logs/default.nix
+++ b/pkgs/development/ocaml-modules/logs/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild
 , topkg, result, lwt, cmdliner, fmt }:
 let
   pname = "logs";
@@ -18,18 +18,13 @@ stdenv.mkDerivation rec {
 
   unpackCmd = "tar xjf $src";
 
-  buildInputs = [ ocaml findlib ocamlbuild opam topkg fmt cmdliner lwt ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg fmt cmdliner lwt ];
   propagatedBuildInputs = [ result ];
 
-  buildPhase = ''
-    ocaml -I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/ pkg/pkg.ml build \
-      --with-js_of_ocaml false
-    '';
+  buildPhase = "${topkg.run} build --with-js_of_ocaml false";
 
   inherit (topkg) installPhase;
 
-  createFindlibDestdir = true;
-
   meta = with stdenv.lib; {
     description = "Logging infrastructure for OCaml";
     homepage = "${webpage}";
diff --git a/pkgs/development/ocaml-modules/mtime/default.nix b/pkgs/development/ocaml-modules/mtime/default.nix
index 534bb4de48c..69921537f5b 100644
--- a/pkgs/development/ocaml-modules/mtime/default.nix
+++ b/pkgs/development/ocaml-modules/mtime/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, ocaml, findlib, ocamlbuild, topkg, opam, js_of_ocaml
+{ stdenv, lib, fetchurl, ocaml, findlib, ocamlbuild, topkg, js_of_ocaml
 , jsooSupport ? true
 }:
 
@@ -25,7 +25,7 @@ stdenv.mkDerivation {
 
   unpackCmd = "tar xjf $src";
 
-  buildInputs = [ ocaml findlib ocamlbuild opam topkg ]
+  buildInputs = [ ocaml findlib ocamlbuild topkg ]
   ++ stdenv.lib.optional jsooSupport js_of_ocaml;
 
   buildPhase = "${topkg.buildPhase} --with-js_of_ocaml ${boolToString jsooSupport}";
diff --git a/pkgs/development/ocaml-modules/nocrypto/default.nix b/pkgs/development/ocaml-modules/nocrypto/default.nix
index a7fa59e1446..cfe3f37800d 100644
--- a/pkgs/development/ocaml-modules/nocrypto/default.nix
+++ b/pkgs/development/ocaml-modules/nocrypto/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, opam, topkg
+{ stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, topkg
 , cpuid, ocb-stubblr
 , cstruct, zarith, ppx_sexp_conv, sexplib
 , cstruct-lwt ? null
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
     sha256 = "0nhnlpbqh3mf9y2cxivlvfb70yfbdpvg6jslzq64xblpgjyg443p";
   };
 
-  buildInputs = [ ocaml findlib ocamlbuild topkg opam cpuid ocb-stubblr
+  buildInputs = [ ocaml findlib ocamlbuild topkg cpuid ocb-stubblr
     ppx_sexp_conv ];
   propagatedBuildInputs = [ cstruct zarith sexplib ] ++ optional withLwt cstruct-lwt;
 
@@ -28,8 +28,6 @@ stdenv.mkDerivation rec {
   '';
   inherit (topkg) installPhase;
 
-  createFindlibDestdir = true;
-
   meta = {
     homepage = https://github.com/mirleft/ocaml-nocrypto;
     description = "Simplest possible crypto to support TLS";
diff --git a/pkgs/development/ocaml-modules/notty/default.nix b/pkgs/development/ocaml-modules/notty/default.nix
index 950395bd7ea..dcc57fddaf6 100644
--- a/pkgs/development/ocaml-modules/notty/default.nix
+++ b/pkgs/development/ocaml-modules/notty/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, buildOcaml, fetchpatch, fetchFromGitHub, findlib, topkg, opam, ocb-stubblr
+{ stdenv, buildOcaml, fetchpatch, fetchFromGitHub, findlib, topkg, ocb-stubblr
 , result, uucp, uuseg, uutf
 , lwt     ? null }:
 
@@ -24,7 +24,7 @@ buildOcaml rec {
     sha256 = "0pklplbnjbsjriqj73pc8fsadg404px534w7zknz2617zb44m6x6";
   })];
 
-  buildInputs = [ findlib opam topkg ocb-stubblr ];
+  buildInputs = [ findlib topkg ocb-stubblr ];
   propagatedBuildInputs = [ result uucp uuseg uutf ] ++
                           optional withLwt lwt;
 
diff --git a/pkgs/development/ocaml-modules/ocb-stubblr/default.nix b/pkgs/development/ocaml-modules/ocb-stubblr/default.nix
index bb4b24cec67..4071cb8a639 100644
--- a/pkgs/development/ocaml-modules/ocb-stubblr/default.nix
+++ b/pkgs/development/ocaml-modules/ocb-stubblr/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchzip, ocaml, findlib, ocamlbuild, opam, topkg, astring }:
+{ stdenv, fetchzip, ocaml, findlib, ocamlbuild, topkg, astring }:
 
 stdenv.mkDerivation {
   name = "ocaml${ocaml.version}-ocb-stubblr-0.1.0";
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
 
   patches = [ ./pkg-config.patch ];
 
-  buildInputs = [ ocaml findlib ocamlbuild opam topkg ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg ];
 
   propagatedBuildInputs = [ astring ];
 
diff --git a/pkgs/development/ocaml-modules/octavius/default.nix b/pkgs/development/ocaml-modules/octavius/default.nix
index f1668160df1..57e3c9bfa74 100644
--- a/pkgs/development/ocaml-modules/octavius/default.nix
+++ b/pkgs/development/ocaml-modules/octavius/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, opam }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg }:
 
 if !stdenv.lib.versionAtLeast ocaml.version "4.03"
 then throw "octavius is not available for OCaml ${ocaml.version}" else
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
 
 	unpackCmd = "tar xjf $src";
 
-	buildInputs = [ ocaml findlib ocamlbuild topkg opam ];
+	buildInputs = [ ocaml findlib ocamlbuild topkg ];
 
 	inherit (topkg) buildPhase installPhase;
 
diff --git a/pkgs/development/ocaml-modules/otfm/default.nix b/pkgs/development/ocaml-modules/otfm/default.nix
index 5deef60520b..05c25c81d5a 100644
--- a/pkgs/development/ocaml-modules/otfm/default.nix
+++ b/pkgs/development/ocaml-modules/otfm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg, uutf, result }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, uutf, result }:
 
 let
   pname = "otfm";
@@ -17,12 +17,10 @@ stdenv.mkDerivation rec {
     sha256 = "054s82539k3kc9na6s47g3scsl04icjahpas7pv5351jmsgqcq3k";
   };
 
-  buildInputs = [ ocaml findlib ocamlbuild opam topkg ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg ];
 
   propagatedBuildInputs = [ uutf result ];
 
-  createFindlibDestdir = true;
-
   unpackCmd = "tar xjf $src";
 
   inherit (topkg) buildPhase installPhase;
diff --git a/pkgs/development/ocaml-modules/otr/default.nix b/pkgs/development/ocaml-modules/otr/default.nix
index 39e7ce754d2..189b3adf873 100644
--- a/pkgs/development/ocaml-modules/otr/default.nix
+++ b/pkgs/development/ocaml-modules/otr/default.nix
@@ -1,7 +1,6 @@
-{stdenv, buildOcaml, fetchFromGitHub, ocamlbuild, findlib, topkg, ocaml, opam,
- ppx_tools, ppx_sexp_conv, cstruct, ppx_cstruct, sexplib, result, nocrypto, astring}:
-
-let ocamlFlags = "-I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/"; in
+{ stdenv, buildOcaml, fetchFromGitHub, ocamlbuild, findlib, topkg, ocaml
+, ppx_tools, ppx_sexp_conv, cstruct, ppx_cstruct, sexplib, result, nocrypto, astring
+}:
 
 buildOcaml rec {
   name = "otr";
@@ -16,23 +15,15 @@ buildOcaml rec {
     sha256 = "07zzix5mfsasqpqdx811m0x04gp8mq1ayf4b64998k98027v01rr";
   };
 
-  buildInputs = [ ocamlbuild findlib topkg ppx_tools ppx_sexp_conv opam ppx_cstruct ];
+  buildInputs = [ ocamlbuild findlib topkg ppx_tools ppx_sexp_conv ppx_cstruct ];
   propagatedBuildInputs = [ cstruct sexplib result nocrypto astring ];
 
-  buildPhase = ''
-    ocaml ${ocamlFlags} pkg/pkg.ml build \
-      --tests true
-  '';
+  buildPhase = "${topkg.run} build --tests true";
 
-  installPhase = ''
-    opam-installer --prefix=$out --script | sh
-    ln -s $out/lib/otr $out/lib/ocaml/${ocaml.version}/site-lib
-  '';
+  inherit (topkg) installPhase;
 
   doCheck = true;
-  checkPhase = "ocaml ${ocamlFlags} pkg/pkg.ml test";
-
-  createFindlibDestdir = true;
+  checkPhase = "${topkg.run} test";
 
   meta = with stdenv.lib; {
     homepage = https://github.com/hannesm/ocaml-otr;
diff --git a/pkgs/development/ocaml-modules/ppx_deriving_yojson/default.nix b/pkgs/development/ocaml-modules/ppx_deriving_yojson/default.nix
index 10f9df04f38..fb06fd7f935 100644
--- a/pkgs/development/ocaml-modules/ppx_deriving_yojson/default.nix
+++ b/pkgs/development/ocaml-modules/ppx_deriving_yojson/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, opam, topkg, cppo
+{ stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, topkg, cppo
 , ppx_import, ppx_deriving, yojson, ounit
 }:
 
@@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
     sha256 = "1pwfnq7z60nchba4gnf58918ll11w3gj5i88qhz1p2jm45hxqgnw";
   };
 
-  buildInputs = [ ocaml findlib ocamlbuild opam cppo ounit ppx_import ];
+  buildInputs = [ ocaml findlib ocamlbuild cppo ounit ppx_import ];
 
   propagatedBuildInputs = [ ppx_deriving yojson ];
 
diff --git a/pkgs/development/ocaml-modules/ptime/default.nix b/pkgs/development/ocaml-modules/ptime/default.nix
index bb4bbef516c..2e3a627a3d1 100644
--- a/pkgs/development/ocaml-modules/ptime/default.nix
+++ b/pkgs/development/ocaml-modules/ptime/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, buildOcaml, ocaml, findlib, ocamlbuild, topkg, result, opam, js_of_ocaml }:
+{ stdenv, fetchurl, buildOcaml, ocaml, findlib, ocamlbuild, topkg, result, js_of_ocaml }:
 
 buildOcaml rec {
   version = "0.8.3";
@@ -11,13 +11,11 @@ buildOcaml rec {
 
   unpackCmd = "tar -xf $curSrc";
 
-  buildInputs = [ ocaml findlib ocamlbuild topkg opam js_of_ocaml ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg js_of_ocaml ];
 
   propagatedBuildInputs = [ result ];
 
-  buildPhase = ''
-    ocaml -I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/ pkg/pkg.ml build --with-js_of_ocaml true
-  '';
+  buildPhase = "${topkg.run} build --with-js_of_ocaml true";
 
   inherit (topkg) installPhase;
 
diff --git a/pkgs/development/ocaml-modules/react/default.nix b/pkgs/development/ocaml-modules/react/default.nix
index 5a720aead80..920ee05244a 100644
--- a/pkgs/development/ocaml-modules/react/default.nix
+++ b/pkgs/development/ocaml-modules/react/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, topkg, ocamlbuild, opam }:
+{ stdenv, fetchurl, ocaml, findlib, topkg, ocamlbuild }:
 
 stdenv.mkDerivation {
   name = "ocaml-react-1.2.1";
@@ -9,9 +9,7 @@ stdenv.mkDerivation {
   };
 
   unpackCmd = "tar xjf $src";
-  buildInputs = [ ocaml findlib topkg ocamlbuild opam ];
-
-  createFindlibDestdir = true;
+  buildInputs = [ ocaml findlib topkg ocamlbuild ];
 
   inherit (topkg) buildPhase installPhase;
 
diff --git a/pkgs/development/ocaml-modules/rresult/default.nix b/pkgs/development/ocaml-modules/rresult/default.nix
index f9951b56da2..d1a796a58e5 100644
--- a/pkgs/development/ocaml-modules/rresult/default.nix
+++ b/pkgs/development/ocaml-modules/rresult/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg }:
 
 stdenv.mkDerivation rec {
 	name = "ocaml${ocaml.version}-rresult-${version}";
@@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
 
 	unpackCmd = "tar xjf $src";
 
-	buildInputs = [ ocaml findlib ocamlbuild topkg opam ];
+	buildInputs = [ ocaml findlib ocamlbuild topkg ];
 
 	inherit (topkg) buildPhase installPhase;
 
diff --git a/pkgs/development/ocaml-modules/topkg/default.nix b/pkgs/development/ocaml-modules/topkg/default.nix
index ecd806ecadc..9a655e05513 100644
--- a/pkgs/development/ocaml-modules/topkg/default.nix
+++ b/pkgs/development/ocaml-modules/topkg/default.nix
@@ -1,9 +1,25 @@
+/* Topkg is a packager for distributing OCaml software. This derivation
+provides facilities to describe derivations for OCaml libraries
+using topkg.
+The `buildPhase` and `installPhase` attributes can be reused directly
+in many cases. When more fine-grained control on how to run the “topkg”
+build system is required, the attribute `run` can be used.
+*/
 { stdenv, fetchurl, ocaml, findlib, ocamlbuild, result, opam }:
 
 if !stdenv.lib.versionAtLeast ocaml.version "4.01"
 then throw "topkg is not available for OCaml ${ocaml.version}"
 else
 
+let
+/* This command allows to run the “topkg” build system.
+ * It is usually called with `build` or `test` as argument.
+ * Packages that use `topkg` may call this command as part of
+ *  their `buildPhase` or `checkPhase`.
+*/
+  run = "ocaml -I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/ pkg/pkg.ml";
+in
+
 stdenv.mkDerivation rec {
   name = "ocaml${ocaml.version}-topkg-${version}";
   version = "0.9.1";
@@ -13,14 +29,15 @@ stdenv.mkDerivation rec {
     sha256 = "1slrzbmyp81xhgsfwwqs2d6gxzvqx0gcp34rq00h5iblhcq7myx6";
   };
 
-  nativeBuildInputs = [ opam ];
   buildInputs = [ ocaml findlib ocamlbuild ];
   propagatedBuildInputs = [ result ];
 
   unpackCmd = "tar xjf ${src}";
-  buildPhase = "ocaml -I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/ pkg/pkg.ml build";
+  buildPhase = "${run} build";
   createFindlibDestdir = true;
-  installPhase = "opam-installer -i --prefix=$out --libdir=$OCAMLFIND_DESTDIR";
+  installPhase = "${opam}/bin/opam-installer -i --prefix=$out --libdir=$OCAMLFIND_DESTDIR";
+
+  passthru = { inherit run; };
 
   meta = {
     homepage = http://erratique.ch/software/topkg;
diff --git a/pkgs/development/ocaml-modules/tsdl/default.nix b/pkgs/development/ocaml-modules/tsdl/default.nix
index 1b90a539ac8..4230d098e0d 100644
--- a/pkgs/development/ocaml-modules/tsdl/default.nix
+++ b/pkgs/development/ocaml-modules/tsdl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, ctypes, result, SDL2, pkgconfig, opam, ocb-stubblr }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, ctypes, result, SDL2, pkgconfig, ocb-stubblr }:
 
 if !stdenv.lib.versionAtLeast ocaml.version "4.02"
 then throw "tsdl is not available for OCaml ${ocaml.version}"
@@ -19,11 +19,9 @@ stdenv.mkDerivation {
   };
 
   nativeBuildInputs = [ pkgconfig ];
-  buildInputs = [ ocaml findlib ocamlbuild topkg result opam ocb-stubblr ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg result ocb-stubblr ];
   propagatedBuildInputs = [ SDL2 ctypes ];
 
-  createFindlibDestdir = true;
-
   unpackCmd = "tar xjf $src";
 
   preConfigure = ''
diff --git a/pkgs/development/ocaml-modules/uucd/default.nix b/pkgs/development/ocaml-modules/uucd/default.nix
index 89d9d545e57..60429ca4b40 100644
--- a/pkgs/development/ocaml-modules/uucd/default.nix
+++ b/pkgs/development/ocaml-modules/uucd/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, xmlm, topkg }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, xmlm, topkg }:
 
 let
   pname = "uucd";
@@ -13,9 +13,7 @@ stdenv.mkDerivation rec {
     sha256 = "0cdyg6vaic4n58w80qriwvaq1c40ng3fh74ilxrwajbq163k055q";
   };
 
-  buildInputs = [ ocaml findlib ocamlbuild opam topkg ];
-
-  createFindlibDestdir = true;
+  buildInputs = [ ocaml findlib ocamlbuild topkg ];
 
   unpackCmd = "tar xjf $src";
 
diff --git a/pkgs/development/ocaml-modules/uucp/default.nix b/pkgs/development/ocaml-modules/uucp/default.nix
index cf5b0549233..66f1ebeba94 100644
--- a/pkgs/development/ocaml-modules/uucp/default.nix
+++ b/pkgs/development/ocaml-modules/uucp/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg, uchar, uutf, uunf }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, uchar, uutf, uunf }:
 
 let
   pname = "uucp";
@@ -17,12 +17,10 @@ stdenv.mkDerivation {
     sha256 = "0qgbrx3lnrzii8a9f0hv4kp73y57q6fr79hskxxxs70q68j2xpfm";
   };
 
-  buildInputs = [ ocaml findlib ocamlbuild opam topkg uutf uunf ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg uutf uunf ];
 
   propagatedBuildInputs = [ uchar ];
 
-  createFindlibDestdir = true;
-
   unpackCmd = "tar xjf $src";
 
   buildPhase = "${topkg.buildPhase} --with-cmdliner false";
diff --git a/pkgs/development/ocaml-modules/uuidm/default.nix b/pkgs/development/ocaml-modules/uuidm/default.nix
index 5a1689eaeeb..b295143c0bc 100644
--- a/pkgs/development/ocaml-modules/uuidm/default.nix
+++ b/pkgs/development/ocaml-modules/uuidm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, opam, cmdliner }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, cmdliner }:
 
 stdenv.mkDerivation rec {
   version = "0.9.6";
@@ -10,12 +10,10 @@ stdenv.mkDerivation rec {
 
   unpackCmd = "tar -xf $curSrc";
 
-  buildInputs = [ ocaml findlib ocamlbuild topkg opam cmdliner ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg cmdliner ];
 
   inherit (topkg) buildPhase installPhase;
 
-  createFindlibDestdir = true;
-
   meta = with stdenv.lib; {
     description = "An OCaml module implementing 128 bits universally unique identifiers version 3, 5 (name based with MD5, SHA-1 hashing) and 4 (random based) according to RFC 4122";
     homepage = http://erratique.ch/software/uuidm;
diff --git a/pkgs/development/ocaml-modules/uunf/default.nix b/pkgs/development/ocaml-modules/uunf/default.nix
index d65f002ebef..e70a539302f 100644
--- a/pkgs/development/ocaml-modules/uunf/default.nix
+++ b/pkgs/development/ocaml-modules/uunf/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg, uchar, uutf, cmdliner }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, uchar, uutf, cmdliner }:
 let
   pname = "uunf";
   webpage = "http://erratique.ch/software/${pname}";
@@ -15,12 +15,10 @@ stdenv.mkDerivation rec {
     sha256 = "0c5lwica5668ybsffllk6x4p921nw4pljimgqikhf17k5hvyjsbr";
   };
 
-  buildInputs = [ ocaml findlib ocamlbuild opam topkg uutf cmdliner ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg uutf cmdliner ];
 
   propagatedBuildInputs = [ uchar ];
 
-  createFindlibDestdir = true;
-
   unpackCmd = "tar xjf $src";
 
   inherit (topkg) buildPhase installPhase;
diff --git a/pkgs/development/ocaml-modules/uuseg/default.nix b/pkgs/development/ocaml-modules/uuseg/default.nix
index f55b757eb26..f27612510c3 100644
--- a/pkgs/development/ocaml-modules/uuseg/default.nix
+++ b/pkgs/development/ocaml-modules/uuseg/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg, uchar, uucp, uutf, cmdliner }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, uchar, uucp, uutf, cmdliner }:
 
 let
   pname = "uuseg";
@@ -15,11 +15,9 @@ stdenv.mkDerivation rec {
     sha256 = "01q8ljjgi7d73x7ms489b5my83xds4jax1vbjhwwjdai01friscc";
   };
 
-  buildInputs = [ ocaml findlib ocamlbuild opam cmdliner topkg uutf ];
+  buildInputs = [ ocaml findlib ocamlbuild cmdliner topkg uutf ];
   propagatedBuildInputs = [ uucp uchar ];
 
-  createFindlibDestdir = true;
-
   unpackCmd = "tar xjf $src";
 
   inherit (topkg) buildPhase installPhase;
diff --git a/pkgs/development/ocaml-modules/uutf/default.nix b/pkgs/development/ocaml-modules/uutf/default.nix
index 93e3fd9c9d2..95ec93d8584 100644
--- a/pkgs/development/ocaml-modules/uutf/default.nix
+++ b/pkgs/development/ocaml-modules/uutf/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, cmdliner , topkg, uchar }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, cmdliner , topkg, uchar }:
 let
   pname = "uutf";
   webpage = "http://erratique.ch/software/${pname}";
@@ -13,11 +13,9 @@ stdenv.mkDerivation rec {
     sha256 = "1gp96dcggq7s84934vimxh89caaxa77lqiff1yywbwkilkkjcfqj";
   };
 
-  buildInputs = [ ocaml findlib ocamlbuild topkg opam cmdliner ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg cmdliner ];
   propagatedBuildInputs = [ uchar ];
 
-  createFindlibDestdir = true;
-
   unpackCmd = "tar xjf $src";
 
   inherit (topkg) buildPhase installPhase;
diff --git a/pkgs/development/ocaml-modules/vg/default.nix b/pkgs/development/ocaml-modules/vg/default.nix
index 0ef3ef4939b..8a8668df74e 100644
--- a/pkgs/development/ocaml-modules/vg/default.nix
+++ b/pkgs/development/ocaml-modules/vg/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg
+{ stdenv, lib, fetchurl, ocaml, findlib, ocamlbuild, topkg
 , uchar, result, gg, uutf, otfm
 , js_of_ocaml, js_of_ocaml-ocamlbuild, js_of_ocaml-ppx,
   pdfBackend ? true, # depends on uutf and otfm
@@ -26,14 +26,12 @@ stdenv.mkDerivation rec {
     sha256 = "1czd2fq85hy24w5pllarsq4pvbx9rda5zdikxfxdng8s9kff2h3f";
   };
 
-  buildInputs = [ ocaml findlib ocamlbuild opam topkg ];
+  buildInputs = [ ocaml findlib ocamlbuild topkg ];
 
   propagatedBuildInputs = [ uchar result gg ]
                           ++ optionals pdfBackend [ uutf otfm ]
                           ++ optionals htmlcBackend [ js_of_ocaml js_of_ocaml-ocamlbuild js_of_ocaml-ppx ];
 
-  createFindlibDestdir = true;
-
   unpackCmd = "tar xjf $src";
 
   buildPhase = topkg.buildPhase
diff --git a/pkgs/development/ocaml-modules/xmlm/default.nix b/pkgs/development/ocaml-modules/xmlm/default.nix
index 7f5bcb03ad6..9d3a0b1bb4d 100644
--- a/pkgs/development/ocaml-modules/xmlm/default.nix
+++ b/pkgs/development/ocaml-modules/xmlm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, opam, topkg }:
+{ stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg }:
 let
   pname = "xmlm";
   webpage = "http://erratique.ch/software/${pname}";
@@ -30,19 +30,12 @@ stdenv.mkDerivation rec {
     inherit (param) sha256;
   };
 
-  buildInputs = [ ocaml findlib ocamlbuild opam ] ++ param.buildInputs;
-
-  createFindlibDestdir = true;
+  buildInputs = [ ocaml findlib ocamlbuild ] ++ param.buildInputs;
 
   unpackCmd = "tar xjf $src";
 
   inherit (param) buildPhase;
-
-  installPhase = ''
-    opam-installer --script --prefix=$out ${pname}.install > install.sh
-    sh install.sh
-    ln -s $out/lib/${pname} $out/lib/ocaml/${ocaml.version}/site-lib/
-  '';
+  inherit (topkg) installPhase;
 
   meta = with stdenv.lib; {
     description = "An OCaml streaming codec to decode and encode the XML data format";