summary refs log tree commit diff
path: root/pkgs/development/ocaml-modules/cstruct
diff options
context:
space:
mode:
authorsternenseemann <git@lukasepple.de>2016-11-03 01:14:44 +0100
committersternenseemann <git@lukasepple.de>2016-11-03 14:24:52 +0100
commit361975cd93dd9ca73153cb74b3af99348cb9313e (patch)
tree8bd689c66ff8624bdd70c252b6e335d2a8186a0e /pkgs/development/ocaml-modules/cstruct
parentd8686b4949b4d67844f8f9047167fc85bfbeca08 (diff)
downloadnixpkgs-361975cd93dd9ca73153cb74b3af99348cb9313e.tar
nixpkgs-361975cd93dd9ca73153cb74b3af99348cb9313e.tar.gz
nixpkgs-361975cd93dd9ca73153cb74b3af99348cb9313e.tar.bz2
nixpkgs-361975cd93dd9ca73153cb74b3af99348cb9313e.tar.lz
nixpkgs-361975cd93dd9ca73153cb74b3af99348cb9313e.tar.xz
nixpkgs-361975cd93dd9ca73153cb74b3af99348cb9313e.tar.zst
nixpkgs-361975cd93dd9ca73153cb74b3af99348cb9313e.zip
ocaml-cstruct: 1.6.0 -> 2.3.0
This commit also refactors the expression.
Diffstat (limited to 'pkgs/development/ocaml-modules/cstruct')
-rw-r--r--pkgs/development/ocaml-modules/cstruct/default.nix44
1 files changed, 32 insertions, 12 deletions
diff --git a/pkgs/development/ocaml-modules/cstruct/default.nix b/pkgs/development/ocaml-modules/cstruct/default.nix
index c9f04918d17..0c011bab0fd 100644
--- a/pkgs/development/ocaml-modules/cstruct/default.nix
+++ b/pkgs/development/ocaml-modules/cstruct/default.nix
@@ -1,20 +1,40 @@
-{stdenv, writeText, fetchurl, ocaml, ocplib-endian, sexplib_p4, findlib,
- async_p4 ? null, lwt ? null, camlp4}:
+{stdenv, buildOcaml, fetchFromGitHub, writeText,
+ ocaml, ocplib-endian, sexplib_p4, findlib, ounit, camlp4,
+ async_p4  ? null, lwt     ? null, ppx_tools ? null,
+ withAsync ? true, withLwt ? true, withPpx   ? true}:
 
-assert stdenv.lib.versionAtLeast (stdenv.lib.getVersion ocaml) "4.01";
+with stdenv.lib;
+assert withAsync -> async_p4 != null;
+assert withLwt -> lwt != null;
+assert withPpx -> ppx_tools != null;
 
-stdenv.mkDerivation {
-  name = "ocaml-cstruct-1.6.0";
+buildOcaml rec {
+  name = "cstruct";
+  version = "2.3.0";
 
-  src = fetchurl {
-    url = https://github.com/mirage/ocaml-cstruct/archive/v1.6.0.tar.gz;
-    sha256 = "0f90a1b7a03091cf22a3ccb11a0cce03b6500f064ad3766b5ed81418ac008ece";
+  minimumSupportedOcamlVersion = "4.02";
+
+  src = fetchFromGitHub {
+    owner = "mirage";
+    repo = "ocaml-cstruct";
+    rev = "v${version}";
+    sha256 = "19spsgkry41dhsbm6ij71kws90bqp7wiggc6lsqdl43xxvbgdmys";
   };
 
-  configureFlags = stdenv.lib.strings.concatStringsSep " " ((if lwt != null then ["--enable-lwt"] else []) ++
-                                          (if async_p4 != null then ["--enable-async"] else []));
-  buildInputs = [ocaml findlib camlp4];
-  propagatedBuildInputs = [ocplib-endian sexplib_p4 lwt async_p4];
+  configureFlags = [ "--enable-tests" ] ++
+                   optional withLwt [ "--enable-lwt" ] ++
+                   optional withAsync [ "--enable-async" ] ++
+                   optional withPpx ["--enable-ppx"];
+  configurePhase = "./configure --prefix $out $configureFlags";
+
+  buildInputs = [ ocaml findlib camlp4 ounit ];
+  propagatedBuildInputs = [ocplib-endian sexplib_p4 ] ++
+                          optional withPpx ppx_tools ++
+                          optional withAsync async_p4 ++
+                          optional withLwt lwt;
+
+  doCheck = true;
+  checkTarget = "test";
 
   createFindlibDestdir = true;
   dontStrip = true;