<commit_before>{ lib, stdenv, fetchurl, fetchFromGitHub, ocaml, findlib, pkg-config, gtk2, libgnomecanvas, gtksourceview }:

let param =
  let check = lib.versionAtLeast ocaml.version; in
  if check "4.06" then rec {
    version = "2.18.12";
    src = fetchFromGitHub {
      owner = "garrigue";
      repo = "lablgtk";
      rev = version;
      sha256 = "sha256:0asib87c42apwf1ln8541x6i3mvyajqbarifvz11in0mqn5k7g7h";
    };
  } else if check "3.12" then {
    version = "2.18.5";
    src = fetchurl {
      url = "https://forge.ocamlcore.org/frs/download.php/1627/lablgtk-2.18.5.tar.gz";
      sha256 = "0cyj6sfdvzx8hw7553lhgwc0krlgvlza0ph3dk9gsxy047dm3wib";
    };
  } else throw "lablgtk is not available for OCaml ${ocaml.version}";
in

stdenv.mkDerivation {
  pname = "lablgtk";
  inherit (param) version src;

  nativeBuildInputs = [ pkg-config ocaml findlib ];
  buildInputs = [ gtk2 libgnomecanvas gtksourceview ];

  configureFlags = [ "--with-libdir=$(out)/lib/ocaml/${ocaml.version}/site-lib" ];
  buildFlags = [ "world" ];

  preInstall = ''
    mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib
    export OCAMLPATH=$out/lib/ocaml/${ocaml.version}/site-lib/:$OCAMLPATH
  '';

  dontStrip = true;

  meta = with lib; {
    description = "An OCaml interface to GTK";
    homepage = "http://lablgtk.forge.ocamlcore.org/";
    license = licenses.lgpl21Plus;
    maintainers = with maintainers; [ <NAME> vbgl ];
    mainProgram = "lablgtk2";
    inherit (ocaml.meta) platforms;
  };
}<commit_msg>ocaml-ng.ocamlPackages_4_05.lablgtk: add -fcommon workaround<commit_after>{ lib, stdenv, fetchurl, fetchFromGitHub, ocaml, findlib, pkg-config, gtk2, libgnomecanvas, gtksourceview }:

let param =
  let check = lib.versionAtLeast ocaml.version; in
  if check "4.06" then rec {
    version = "2.18.12";
    src = fetchFromGitHub {
      owner = "garrigue";
      repo = "lablgtk";
      rev = version;
      sha256 = "sha256:0asib87c42apwf1ln8541x6i3mvyajqbarifvz11in0mqn5k7g7h";
    };
    NIX_CFLAGS_COMPILE = null;
  } else if check "3.12" then {
    version = "2.18.5";
    src = fetchurl {
      url = "https://forge.ocamlcore.org/frs/download.php/1627/lablgtk-2.18.5.tar.gz";
      sha256 = "0cyj6sfdvzx8hw7553lhgwc0krlgvlza0ph3dk9gsxy047dm3wib";
    };
    # Workaround build failure on -fno-common toolchains like upstream
    # gcc-10. Otherwise build fails as:
    #   ld: ml_gtktree.o:(.bss+0x0): multiple definition of
    #     `ml_table_extension_events'; ml_gdkpixbuf.o:(.bss+0x0): first defined here
    NIX_CFLAGS_COMPILE = "-fcommon";
  } else throw "lablgtk is not available for OCaml ${ocaml.version}";
in

stdenv.mkDerivation {
  pname = "lablgtk";
  inherit (param) version src NIX_CFLAGS_COMPILE;

  nativeBuildInputs = [ pkg-config ocaml findlib ];
  buildInputs = [ gtk2 libgnomecanvas gtksourceview ];

  configureFlags = [ "--with-libdir=$(out)/lib/ocaml/${ocaml.version}/site-lib" ];
  buildFlags = [ "world" ];

  preInstall = ''
    mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib
    export OCAMLPATH=$out/lib/ocaml/${ocaml.version}/site-lib/:$OCAMLPATH
  '';

  dontStrip = true;

  meta = with lib; {
    description = "An OCaml interface to GTK";
    homepage = "http://lablgtk.forge.ocamlcore.org/";
    license = licenses.lgpl21Plus;
    maintainers = with maintainers; [ maggesi roconnor vbgl ];
    mainProgram = "lablgtk2";
    inherit (ocaml.meta) platforms;
  };
}
{'fraction_non_alphanumeric': 0.13636363636363635, 'fraction_numerical': 0.0436950146627566, 'mean_word_length': 3.44140625, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4734050', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1324, 'n_words': 248}