summary refs log tree commit diff
path: root/pkgs/development/ocaml-modules/cstruct
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/ocaml-modules/cstruct')
-rw-r--r--pkgs/development/ocaml-modules/cstruct/1.9.0.nix36
-rw-r--r--pkgs/development/ocaml-modules/cstruct/async.nix11
-rw-r--r--pkgs/development/ocaml-modules/cstruct/default.nix16
-rw-r--r--pkgs/development/ocaml-modules/cstruct/lwt.nix8
-rw-r--r--pkgs/development/ocaml-modules/cstruct/ppx.nix28
-rw-r--r--pkgs/development/ocaml-modules/cstruct/sexp.nix14
-rw-r--r--pkgs/development/ocaml-modules/cstruct/unix.nix8
7 files changed, 63 insertions, 58 deletions
diff --git a/pkgs/development/ocaml-modules/cstruct/1.9.0.nix b/pkgs/development/ocaml-modules/cstruct/1.9.0.nix
deleted file mode 100644
index 1cea58abee2..00000000000
--- a/pkgs/development/ocaml-modules/cstruct/1.9.0.nix
+++ /dev/null
@@ -1,36 +0,0 @@
-{ stdenv, fetchFromGitHub, ocaml, ocamlbuild, ocplib-endian, sexplib, findlib, ppx_tools
-, async ? null, lwt ? null
-}:
-
-assert stdenv.lib.versionAtLeast ocaml.version "4.01";
-
-let version = "1.9.0"; in
-
-let opt = b: "--${if b != null then "en" else "dis"}able"; in
-
-stdenv.mkDerivation {
-  name = "ocaml${ocaml.version}-cstruct-${version}";
-
-  src = fetchFromGitHub {
-    owner = "mirage";
-    repo = "ocaml-cstruct";
-    rev = "v${version}";
-    sha256 = "1c1j21zgmxi9spq23imy7byn50qr7hlds1cfpzxlsx9dp309jngy";
-  };
-
-  configureFlags = [ "${opt lwt}-lwt" "${opt async}-async" "${opt ppx_tools}-ppx" ];
-
-  buildInputs = [ ocaml findlib ocamlbuild ppx_tools lwt async ];
-  propagatedBuildInputs = [ ocplib-endian sexplib ];
-
-  createFindlibDestdir = true;
-  dontStrip = true;
-
-  meta = with stdenv.lib; {
-    homepage = "https://github.com/mirage/ocaml-cstruct";
-    description = "Map OCaml arrays onto C-like structs";
-    license = stdenv.lib.licenses.isc;
-    maintainers = [ maintainers.vbgl maintainers.ericbmerritt ];
-    platforms = ocaml.meta.platforms or [];
-  };
-}
diff --git a/pkgs/development/ocaml-modules/cstruct/async.nix b/pkgs/development/ocaml-modules/cstruct/async.nix
new file mode 100644
index 00000000000..579f12776c0
--- /dev/null
+++ b/pkgs/development/ocaml-modules/cstruct/async.nix
@@ -0,0 +1,11 @@
+{ lib, buildDunePackage, cstruct, async_unix }:
+
+buildDunePackage rec {
+  pname = "cstruct-async";
+  inherit (cstruct) src version meta useDune2;
+
+  propagatedBuildInputs = [
+    async_unix
+    cstruct
+  ];
+}
diff --git a/pkgs/development/ocaml-modules/cstruct/default.nix b/pkgs/development/ocaml-modules/cstruct/default.nix
index 01a32fc09a2..8b0c4ee9ebb 100644
--- a/pkgs/development/ocaml-modules/cstruct/default.nix
+++ b/pkgs/development/ocaml-modules/cstruct/default.nix
@@ -1,14 +1,24 @@
-{ lib, fetchurl, buildDunePackage }:
+{ lib, fetchurl, buildDunePackage, bigarray-compat, alcotest, ocaml }:
 
 buildDunePackage rec {
   pname = "cstruct";
-  version = "4.0.0";
+  version = "6.0.0";
+
+  useDune2 = true;
+
+  minimumOCamlVersion = "4.03";
 
   src = fetchurl {
     url = "https://github.com/mirage/ocaml-cstruct/releases/download/v${version}/cstruct-v${version}.tbz";
-    sha256 = "1q4fsc2m6d96yf42g3wb3gcnhpnxw800df5mh3yr25pprj8y4m1a";
+    sha256 = "0xi6cj85z033fqrqdkwac6gg07629vzdhx03c3lhiwwc4lpnv8bq";
   };
 
+  propagatedBuildInputs = [ bigarray-compat ];
+
+  # alcotest isn't available for OCaml < 4.05 due to fmt
+  doCheck = lib.versionAtLeast ocaml.version "4.05";
+  checkInputs = [ alcotest ];
+
   meta = {
     description = "Access C-like structures directly from OCaml";
     license = lib.licenses.isc;
diff --git a/pkgs/development/ocaml-modules/cstruct/lwt.nix b/pkgs/development/ocaml-modules/cstruct/lwt.nix
index 5a10d7cae48..df8941d1260 100644
--- a/pkgs/development/ocaml-modules/cstruct/lwt.nix
+++ b/pkgs/development/ocaml-modules/cstruct/lwt.nix
@@ -5,10 +5,10 @@ then cstruct
 else
 
 buildDunePackage {
-	pname = "cstruct-lwt";
-	inherit (cstruct) version src meta;
+  pname = "cstruct-lwt";
+  inherit (cstruct) version src useDune2 meta;
 
-  minimumOCamlVersion = "4.02";
+  minimumOCamlVersion = "4.03";
 
-	propagatedBuildInputs = [ cstruct lwt ];
+  propagatedBuildInputs = [ cstruct lwt ];
 }
diff --git a/pkgs/development/ocaml-modules/cstruct/ppx.nix b/pkgs/development/ocaml-modules/cstruct/ppx.nix
index 22fe4ac47cf..aa003295e90 100644
--- a/pkgs/development/ocaml-modules/cstruct/ppx.nix
+++ b/pkgs/development/ocaml-modules/cstruct/ppx.nix
@@ -1,14 +1,32 @@
-{ lib, buildDunePackage, cstruct, sexplib, ppx_tools_versioned }:
+{ lib, buildDunePackage, cstruct, sexplib, ppxlib, stdlib-shims
+, ounit, cppo, ppx_sexp_conv, cstruct-unix, cstruct-sexp
+, fetchpatch
+}:
 
 if !lib.versionAtLeast (cstruct.version or "1") "3"
 then cstruct
 else
 
 buildDunePackage {
-	pname = "ppx_cstruct";
-	inherit (cstruct) version src meta;
+  pname = "ppx_cstruct";
+  inherit (cstruct) version src useDune2 meta;
 
-	minimumOCamlVersion = "4.03";
+  minimumOCamlVersion = "4.07";
 
-	propagatedBuildInputs = [ cstruct ppx_tools_versioned sexplib ];
+  # prevent ANSI escape sequences from messing up the test cases
+  # https://github.com/mirage/ocaml-cstruct/issues/283
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/mirage/ocaml-cstruct/pull/285/commits/60dfed98b4c34455bf339ac60e2ed5ef05feb48f.patch";
+      sha256 = "1x9i62nrlfy9l44vb0a7qjfrg2wyki4c8nmmqnzwpcbkgxi3q6n5";
+    })
+  ];
+
+  propagatedBuildInputs = [ cstruct ppxlib sexplib stdlib-shims ];
+
+  # disable until ppx_sexp_conv uses ppxlib 0.20.0 (or >= 0.16.0)
+  # since the propagation of the older ppxlib breaks the ppx_cstruct
+  # build.
+  doCheck = false;
+  checkInputs = [ ounit cppo ppx_sexp_conv cstruct-sexp cstruct-unix ];
 }
diff --git a/pkgs/development/ocaml-modules/cstruct/sexp.nix b/pkgs/development/ocaml-modules/cstruct/sexp.nix
index d0df442013f..b04810e4803 100644
--- a/pkgs/development/ocaml-modules/cstruct/sexp.nix
+++ b/pkgs/development/ocaml-modules/cstruct/sexp.nix
@@ -5,12 +5,14 @@ then cstruct
 else
 
 buildDunePackage rec {
-	pname = "cstruct-sexp";
-	inherit (cstruct) version src meta;
+  pname = "cstruct-sexp";
+  inherit (cstruct) version src useDune2 meta;
 
-	doCheck = lib.versionAtLeast ocaml.version "4.03";
-	checkInputs = lib.optional doCheck alcotest;
+  minimumOCamlVersion = "4.03";
 
-	propagatedBuildInputs = [ cstruct sexplib ];
-}
+  # alcotest is only available on OCaml >= 4.05 due to fmt
+  doCheck = lib.versionAtLeast ocaml.version "4.05";
+  checkInputs = [ alcotest ];
 
+  propagatedBuildInputs = [ cstruct sexplib ];
+}
diff --git a/pkgs/development/ocaml-modules/cstruct/unix.nix b/pkgs/development/ocaml-modules/cstruct/unix.nix
index 7cb5d665869..1ea27bb04de 100644
--- a/pkgs/development/ocaml-modules/cstruct/unix.nix
+++ b/pkgs/development/ocaml-modules/cstruct/unix.nix
@@ -5,10 +5,10 @@ then cstruct
 else
 
 buildDunePackage {
-	pname = "cstruct-unix";
-	inherit (cstruct) version src meta;
+  pname = "cstruct-unix";
+  inherit (cstruct) version src useDune2 meta;
 
-	minimumOCamlVersion = "4.06";
+  minimumOCamlVersion = "4.06";
 
-	propagatedBuildInputs = [ cstruct ];
+  propagatedBuildInputs = [ cstruct ];
 }