diff --git a/pkgs/development/libraries/libbap/default.nix b/pkgs/development/libraries/libbap/default.nix index ebbf02603cbb..3ed92edd78e1 100644 --- a/pkgs/development/libraries/libbap/default.nix +++ b/pkgs/development/libraries/libbap/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, bap, ocaml, findlib, ctypes, autoreconfHook, +{ lib, stdenv, fetchFromGitHub, bap, ocaml, findlib, ctypes, ctypes-foreign, autoreconfHook, which }: stdenv.mkDerivation { @@ -13,7 +13,7 @@ stdenv.mkDerivation { }; nativeBuildInputs = [ autoreconfHook which ocaml findlib ]; - buildInputs = [ bap ctypes ]; + buildInputs = [ bap ctypes ctypes-foreign ]; preInstall = '' mkdir -p $out/lib diff --git a/pkgs/development/ocaml-modules/ctypes/default.nix b/pkgs/development/ocaml-modules/ctypes/default.nix index fa9cde044e8a..a10abff96b21 100644 --- a/pkgs/development/ocaml-modules/ctypes/default.nix +++ b/pkgs/development/ocaml-modules/ctypes/default.nix @@ -1,49 +1,35 @@ -{ lib, stdenv, fetchFromGitHub, ocaml, findlib, libffi, pkg-config, ncurses, integers, bigarray-compat }: +{ lib +, ocaml +, fetchFromGitHub +, buildDunePackage +, dune-configurator +, integers +, bigarray-compat +, ounit2 +}: -if lib.versionOlder ocaml.version "4.02" -then throw "ctypes is not available for OCaml ${ocaml.version}" -else - -stdenv.mkDerivation rec { - pname = "ocaml${ocaml.version}-ctypes"; - version = "0.20.2"; +buildDunePackage rec { + pname = "ctypes"; + version = "0.21.1"; src = fetchFromGitHub { owner = "ocamllabs"; repo = "ocaml-ctypes"; rev = version; - hash = "sha256-LzUrR8K88CjY/R5yUK3y6KG85hUMjbzuebHGqI8KhhM="; + hash = "sha256-Cay+8dwFxw4d1OgMP4CR94l4ic2269YCAaziesEqwHM="; }; - nativeBuildInputs = [ pkg-config ocaml findlib ]; - buildInputs = [ ncurses ]; - propagatedBuildInputs = [ integers libffi bigarray-compat ]; + buildInputs = [ dune-configurator ]; - strictDeps = true; + propagatedBuildInputs = [ integers bigarray-compat ]; - preConfigure = '' - substituteInPlace META --replace ' bytes ' ' ' - ''; - - buildPhase = '' - runHook preBuild - make XEN=false libffi.config ctypes-base ctypes-stubs - make XEN=false ctypes-foreign - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/stublibs - make install XEN=false - runHook postInstall - ''; + doCheck = lib.versionAtLeast ocaml.version "4.08"; + checkInputs = [ ounit2 ]; meta = with lib; { homepage = "https://github.com/ocamllabs/ocaml-ctypes"; description = "Library for binding to C libraries using pure OCaml"; license = licenses.mit; maintainers = [ maintainers.ericbmerritt ]; - inherit (ocaml.meta) platforms; }; } diff --git a/pkgs/development/ocaml-modules/ctypes/foreign.nix b/pkgs/development/ocaml-modules/ctypes/foreign.nix new file mode 100644 index 000000000000..5c9efad790f2 --- /dev/null +++ b/pkgs/development/ocaml-modules/ctypes/foreign.nix @@ -0,0 +1,23 @@ +{ buildDunePackage +, ctypes +, dune-configurator +, libffi +, ounit2 +, lwt +}: + +buildDunePackage rec { + pname = "ctypes-foreign"; + + inherit (ctypes) version src doCheck; + + buildInputs = [ dune-configurator ]; + + propagatedBuildInputs = [ ctypes libffi ]; + + checkInputs = [ ounit2 lwt ]; + + meta = ctypes.meta // { + description = "Dynamic access to foreign C libraries using Ctypes"; + }; +} diff --git a/pkgs/development/ocaml-modules/hacl-star/raw.nix b/pkgs/development/ocaml-modules/hacl-star/raw.nix index 00b524606fcf..b4b8c1741535 100644 --- a/pkgs/development/ocaml-modules/hacl-star/raw.nix +++ b/pkgs/development/ocaml-modules/hacl-star/raw.nix @@ -27,7 +27,10 @@ stdenv.mkDerivation rec { # strictoverflow is disabled because it breaks aarch64-darwin hardeningDisable = [ "strictoverflow" ]; + # Compatibility with ctypes ≥ 0.21 + # see: https://github.com/cryspen/hacl-packages/commit/81303b83a54a92d3b5f54f1b8ddbea60438cc2bf postPatch = '' + substituteInPlace hacl-star-raw/META --replace-warn 'requires="ctypes"' 'requires="ctypes ctypes.stubs"' patchShebangs ./ ''; diff --git a/pkgs/development/ocaml-modules/janestreet/0.14.nix b/pkgs/development/ocaml-modules/janestreet/0.14.nix index 249f9c3115d6..7d8bdc4dfb7d 100644 --- a/pkgs/development/ocaml-modules/janestreet/0.14.nix +++ b/pkgs/development/ocaml-modules/janestreet/0.14.nix @@ -130,7 +130,7 @@ with self; hash = "0ykys3ckpsx5crfgj26v2q3gy6wf684aq0bfb4q8p92ivwznvlzy"; meta.description = "Async wrappers for SSL"; buildInputs = [ dune-configurator ]; - propagatedBuildInputs = [ async ctypes openssl ]; + propagatedBuildInputs = [ async ctypes ctypes-foreign openssl ]; # in ctypes.foreign 0.18.0 threaded and unthreaded have been merged postPatch = '' substituteInPlace bindings/dune \ diff --git a/pkgs/development/ocaml-modules/janestreet/0.15.nix b/pkgs/development/ocaml-modules/janestreet/0.15.nix index ccd2d4eab299..f64e228a2b81 100644 --- a/pkgs/development/ocaml-modules/janestreet/0.15.nix +++ b/pkgs/development/ocaml-modules/janestreet/0.15.nix @@ -144,7 +144,7 @@ with self; hash = "1b7f7p3xj4jr2n2dxy2lp7a9k7944w6x2nrg6524clvcsd1ax4hn"; meta.description = "Async wrappers for SSL"; buildInputs = [ dune-configurator ]; - propagatedBuildInputs = [ async ctypes openssl ]; + propagatedBuildInputs = [ async ctypes ctypes-foreign openssl ]; # in ctypes.foreign 0.18.0 threaded and unthreaded have been merged postPatch = '' substituteInPlace bindings/dune \ diff --git a/pkgs/development/ocaml-modules/janestreet/0.16.nix b/pkgs/development/ocaml-modules/janestreet/0.16.nix index bba99ebb29d1..562364df53bc 100644 --- a/pkgs/development/ocaml-modules/janestreet/0.16.nix +++ b/pkgs/development/ocaml-modules/janestreet/0.16.nix @@ -146,7 +146,7 @@ with self; hash = "sha256-83YKxvVb/JwBnQG4R/R1Ztik9T/hO4cbiNTfFnErpG4="; meta.description = "Async wrappers for SSL"; buildInputs = [ dune-configurator ]; - propagatedBuildInputs = [ async ctypes openssl ]; + propagatedBuildInputs = [ async ctypes ctypes-foreign openssl ]; }; async_unix = janePackage { diff --git a/pkgs/development/ocaml-modules/lilv/default.nix b/pkgs/development/ocaml-modules/lilv/default.nix index 501182db7a96..a5def260eb29 100644 --- a/pkgs/development/ocaml-modules/lilv/default.nix +++ b/pkgs/development/ocaml-modules/lilv/default.nix @@ -1,4 +1,4 @@ -{ lib, buildDunePackage, fetchFromGitHub, dune-configurator, ctypes, lilv }: +{ lib, buildDunePackage, fetchFromGitHub, dune-configurator, ctypes, ctypes-foreign, lilv }: buildDunePackage rec { pname = "lilv"; @@ -14,7 +14,7 @@ buildDunePackage rec { minimalOCamlVersion = "4.03.0"; buildInputs = [ dune-configurator ]; - propagatedBuildInputs = [ ctypes lilv ]; + propagatedBuildInputs = [ ctypes ctypes-foreign lilv ]; meta = with lib; { homepage = "https://github.com/savonet/ocaml-lilv"; diff --git a/pkgs/development/ocaml-modules/mariadb/default.nix b/pkgs/development/ocaml-modules/mariadb/default.nix index 397402481839..3ac6027b22fd 100644 --- a/pkgs/development/ocaml-modules/mariadb/default.nix +++ b/pkgs/development/ocaml-modules/mariadb/default.nix @@ -15,10 +15,16 @@ stdenv.mkDerivation rec { sha256 = "sha256-3/C1Gz6luUzS7oaudLlDHMT6JB2v5OdbLVzJhtayHGM="; }; - patches = fetchpatch { - url = "https://github.com/andrenth/ocaml-mariadb/commit/9db2e4d8dec7c584213d0e0f03d079a36a35d9d5.patch"; - hash = "sha256-heROtU02cYBJ5edIHMdYP1xNXcLv8h79GYGBuudJhgE="; - }; + patches = lib.lists.map (x: + fetchpatch { + url = "https://github.com/andrenth/ocaml-mariadb/commit/${x.path}.patch"; + inherit (x) hash; + }) + [ { path = "9db2e4d8dec7c584213d0e0f03d079a36a35d9d5"; + hash = "sha256-heROtU02cYBJ5edIHMdYP1xNXcLv8h79GYGBuudJhgE="; } + { path = "40cd3102bc7cce4ed826ed609464daeb1bbb4581"; + hash = "sha256-YVsAMJiOgWRk9xPaRz2sDihBYLlXv+rhWtQIMOVLtSg="; } + ]; postPatch = '' substituteInPlace setup.ml --replace '#use "topfind"' \ diff --git a/pkgs/development/ocaml-modules/srt/default.nix b/pkgs/development/ocaml-modules/srt/default.nix index 92431fcb3489..d1e5ecd9ad55 100644 --- a/pkgs/development/ocaml-modules/srt/default.nix +++ b/pkgs/development/ocaml-modules/srt/default.nix @@ -2,6 +2,7 @@ , dune-configurator , posix-socket , srt +, ctypes-foreign }: buildDunePackage rec { @@ -9,7 +10,6 @@ buildDunePackage rec { version = "0.3.0"; minimalOCamlVersion = "4.08"; - duneVersion = "3"; src = fetchFromGitHub { owner = "savonet"; @@ -19,7 +19,7 @@ buildDunePackage rec { }; buildInputs = [ dune-configurator ]; - propagatedBuildInputs = [ posix-socket srt ]; + propagatedBuildInputs = [ ctypes-foreign posix-socket srt ]; meta = with lib; { description = "OCaml bindings for the libsrt library"; diff --git a/pkgs/development/ocaml-modules/torch/default.nix b/pkgs/development/ocaml-modules/torch/default.nix index a22a9ea68ddc..5acef0f2a72c 100644 --- a/pkgs/development/ocaml-modules/torch/default.nix +++ b/pkgs/development/ocaml-modules/torch/default.nix @@ -5,6 +5,7 @@ , fetchpatch , cmdliner , ctypes +, ctypes-foreign , dune-configurator , npy , ocaml-compiler-libs @@ -42,6 +43,7 @@ buildDunePackage rec { propagatedBuildInputs = [ cmdliner ctypes + ctypes-foreign npy ocaml-compiler-libs ppx_custom_printf diff --git a/pkgs/development/ocaml-modules/tsdl/default.nix b/pkgs/development/ocaml-modules/tsdl/default.nix index 14c29f3daee0..2d35f76d5bf0 100644 --- a/pkgs/development/ocaml-modules/tsdl/default.nix +++ b/pkgs/development/ocaml-modules/tsdl/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, ctypes, result, SDL2, pkg-config +{ lib, stdenv, fetchurl, ocaml, findlib, ocamlbuild, topkg, ctypes, ctypes-foreign, result, SDL2, pkg-config , AudioToolbox, Cocoa, CoreAudio, CoreVideo, ForceFeedback }: if lib.versionOlder ocaml.version "4.03" @@ -24,7 +24,7 @@ stdenv.mkDerivation { nativeBuildInputs = [ pkg-config ocaml findlib ocamlbuild topkg ]; buildInputs = [ topkg ]; - propagatedBuildInputs = [ SDL2 ctypes ] + propagatedBuildInputs = [ SDL2 ctypes ctypes-foreign ] ++ lib.optionals stdenv.isDarwin [ AudioToolbox Cocoa CoreAudio CoreVideo ForceFeedback ]; preConfigure = '' diff --git a/pkgs/development/ocaml-modules/xxhash/default.nix b/pkgs/development/ocaml-modules/xxhash/default.nix index fe212dd0eb70..d8ef8f3d60ef 100644 --- a/pkgs/development/ocaml-modules/xxhash/default.nix +++ b/pkgs/development/ocaml-modules/xxhash/default.nix @@ -3,6 +3,7 @@ , buildDunePackage , xxHash , ctypes +, ctypes-foreign , dune-configurator , ppx_expect }: @@ -20,12 +21,17 @@ buildDunePackage rec { hash = "sha256-0+ac5EWV9DCVMT4wOcXC95GVEwsUIZzFn2laSzmK6jE="; }; + postPatch = '' + substituteInPlace stubs/dune --replace-warn 'ctypes))' 'ctypes ctypes.stubs))' + ''; + buildInputs = [ dune-configurator ]; propagatedBuildInputs = [ ctypes + ctypes-foreign xxHash ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 36d721bdcf84..a52ea0f43ace 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -22209,7 +22209,7 @@ with pkgs; libbacktrace = callPackage ../development/libraries/libbacktrace { }; libbap = callPackage ../development/libraries/libbap { - inherit (ocaml-ng.ocamlPackages_4_14) bap ocaml findlib ctypes; + inherit (ocaml-ng.ocamlPackages_4_14) bap ocaml findlib ctypes ctypes-foreign; }; libbaseencode = callPackage ../development/libraries/libbaseencode { }; diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 354e3a4e6d64..3b49788c4f40 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -283,6 +283,8 @@ let ctypes = callPackage ../development/ocaml-modules/ctypes { }; + ctypes-foreign = callPackage ../development/ocaml-modules/ctypes/foreign.nix { }; + ctypes_stubs_js = callPackage ../development/ocaml-modules/ctypes_stubs_js { inherit (pkgs) nodejs; }; @@ -786,7 +788,7 @@ let inherit conduit ipaddr-sexp; }; in { - inherit (self) dune-configurator alcotest re num octavius uutf ounit ctypes; + inherit (self) dune-configurator alcotest re num octavius uutf ounit ctypes ctypes-foreign; ppxlib = self.ppxlib.override { inherit (self') stdio; }; cohttp-async = self.cohttp-async.override { inherit (self') ppx_sexp_conv base async async_kernel async_unix core_unix sexplib0 core;