<commit_before>{ lib, stdenv, fetchFromGitHub, ocaml, findlib, libffi, pkg-config, ncurses, integers, bigarray-compat }:

if !lib.versionAtLeast 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.18.0";

  src = fetchFromGitHub {
    owner = "ocamllabs";
    repo = "ocaml-ctypes";
    rev = version;
    sha256 = "sha256-eu5RAuPYC97IM4XUsUw3HQ1BJlEHQ+eBpsdUE6hd+Q8=";
  };

  nativeBuildInputs = [ pkg-config ];
  buildInputs = [ ocaml findlib ncurses ];
  propagatedBuildInputs = [ integers libffi bigarray-compat ];

  buildPhase = ''
    make XEN=false libffi.config ctypes-base ctypes-stubs
    make XEN=false ctypes-foreign
  '';

  installPhase = ''
    mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/stublibs<commit_msg>ocamlPackages.ctypes: 0.18.0 -> 0.20.0<commit_after>{ lib, stdenv, fetchFromGitHub, ocaml, findlib, libffi, pkg-config, ncurses, integers, bigarray-compat }:

if !lib.versionAtLeast 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.0";

  src = fetchFromGitHub {
    owner = "ocamllabs";
    repo = "ocaml-ctypes";
    rev = version;
    sha256 = "sha256-fr60H/hiSVjEg11qM8LF1Y5CotS3FEyFdCcIh0A0uI4=";
  };

  nativeBuildInputs = [ pkg-config ];
  buildInputs = [ ocaml findlib ncurses ];
  propagatedBuildInputs = [ integers libffi bigarray-compat ];

  buildPhase = ''
    make XEN=false libffi.config ctypes-base ctypes-stubs
    make XEN=false ctypes-foreign
  '';

  installPhase = ''
    mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/stublibs
{'fraction_non_alphanumeric': 0.1309867282169648, 'fraction_numerical': 0.030582804385458743, 'mean_word_length': 3.968481375358166, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5037983', 'n_tokens_mistral': 716, 'n_tokens_neox': 686, 'n_words': 129}