<commit_before>{ stdenv, fetchurl, fetchFromGitHub, cmake, openssl, sqlite, pkgconfig, systemd
, tlsSupport ? false }:

assert tlsSupport -> openssl != null;

stdenv.mkDerivation rec {
  name = "uhub-${version}";
  version = "0.5.0";

  src = fetchFromGitHub {
    owner = "janvidar";
    repo = "uhub";
    rev = version;
    sha256 = "0zdbxfvw7apmfhqgsfkfp4pn9iflzwdn0zwvzymm5inswfc00pxg";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ cmake sqlite systemd ] ++ stdenv.lib.optional tlsSupport openssl;

  outputs = [ "out"
    "mod_example"
    "mod_welcome"
    "mod_logging"
    "mod_auth_simple"
    "mod_auth_sqlite"
    "mod_chat_history"
    "mod_chat_only"
    "mod_topic"
    "mod_no_guest_downloads"
  ];

  patches = [
    ./plugin-dir.patch

    # Fixed compilation on systemd > 210
    (fetchurl {
      url = "https://github.com/janvidar/uhub/commit/70f2a43f676cdda5961950a8d9a21e12d34993f8.diff";<commit_msg>uhub: fix build for aarch64<commit_after>{ stdenv, fetchpatch, fetchFromGitHub, cmake, openssl, sqlite, pkgconfig, systemd
, tlsSupport ? false }:

assert tlsSupport -> openssl != null;

stdenv.mkDerivation rec {
  name = "uhub-${version}";
  version = "0.5.0";

  src = fetchFromGitHub {
    owner = "janvidar";
    repo = "uhub";
    rev = version;
    sha256 = "0zdbxfvw7apmfhqgsfkfp4pn9iflzwdn0zwvzymm5inswfc00pxg";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ cmake sqlite systemd ] ++ stdenv.lib.optional tlsSupport openssl;

  outputs = [ "out"
    "mod_example"
    "mod_welcome"
    "mod_logging"
    "mod_auth_simple"
    "mod_auth_sqlite"
    "mod_chat_history"
    "mod_chat_only"
    "mod_topic"
    "mod_no_guest_downloads"
  ];

  patches = [
    ./plugin-dir.patch
    # fix aarch64 build: https://github.com/janvidar/uhub/issues/46
    (fetchpatch {
      url = "https://github.com/janvidar/uhub/pull/47.patch";
      sha256 = "07yik6za89ar5bxm7m2183i7f6hfbawbxvd4vs02n1zr2fgfxmiq";
    })

    # Fixed compilation on systemd > 210
    (fetchpatch {
      url = "https://github.com/janvidar/uhub/commit/70f2a43f676cdda5961950a8d9a21e12d34993f8.diff";
{'fraction_non_alphanumeric': 0.12158341187558906, 'fraction_numerical': 0.05513666352497644, 'mean_word_length': 3.536324786324786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, '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': '7633452', 'n_tokens_mistral': 924, 'n_tokens_neox': 847, 'n_words': 134}