<commit_before>{ stdenv
, fetchTritonPatch
, fetchurl

, readline

, channel
}:

let
  sources = {
    "5.2" = {
      version = "5.2.4";
      multihash = "QmWJdzGBRfifvof4krhv3FRPFxD2FUmz6VcQ83emcoGTML";
      sha256 = "b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b";
    };
    "5.3" = {
      version = "5.3.4";
      multihash = "QmNYqRyfDBStum87ptEAZWBbjAXKC6pmZX9vuJzcdhK5Ru";
      sha256 = "f681aa518233bc407e23acf0f5887c884f17436f000d453b2491a9f11a52400c";
    };
  };
  source = sources."${channel}";
in
stdenv.mkDerivation rec {
  name = "lua-${source.version}";

  src = fetchurl {
    url = "https://www.lua.org/ftp/${name}.tar.gz";
    inherit (source)
      multihash
      sha256;
  };

  buildInputs = [
    readline
  ];

  patches = [
    (fetchTritonPatch {
      rev = "0619357d1bd2ab053c2fb3532d959660eaca6433";
      file = "l/lua/liblua.so.patch";
      sha256 = "2cc83c77423a2dda3696766b2d1ccee2796e052ab04d5178905f41ed9241a3d8";
    })
  ];

  postPatch = ''
    sed -i src/luaconf.h \
      -e "/LUA_ROOT/ s,/usr/,$out,"<commit_msg>lua: Fix broken substitution<commit_after>{ stdenv
, fetchTritonPatch
, fetchurl

, readline

, channel
}:

let
  sources = {
    "5.2" = {
      version = "5.2.4";
      multihash = "QmWJdzGBRfifvof4krhv3FRPFxD2FUmz6VcQ83emcoGTML";
      sha256 = "b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b";
    };
    "5.3" = {
      version = "5.3.4";
      multihash = "QmNYqRyfDBStum87ptEAZWBbjAXKC6pmZX9vuJzcdhK5Ru";
      sha256 = "f681aa518233bc407e23acf0f5887c884f17436f000d453b2491a9f11a52400c";
    };
  };
  source = sources."${channel}";
in
stdenv.mkDerivation rec {
  name = "lua-${source.version}";

  src = fetchurl {
    url = "https://www.lua.org/ftp/${name}.tar.gz";
    inherit (source)
      multihash
      sha256;
  };

  buildInputs = [
    readline
  ];

  patches = [
    (fetchTritonPatch {
      rev = "0619357d1bd2ab053c2fb3532d959660eaca6433";
      file = "l/lua/liblua.so.patch";
      sha256 = "2cc83c77423a2dda3696766b2d1ccee2796e052ab04d5178905f41ed9241a3d8";
    })
  ];

  postPatch = ''
    sed -i "/LUA_ROOT/ s,/usr,$out," src/luaconf.h
{'fraction_non_alphanumeric': 0.13234613604812587, 'fraction_numerical': 0.16844053678852383, 'mean_word_length': 3.118095238095238, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '795295', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1004, 'n_words': 109}