<commit_before>{ stdenv, fetchurl, autoreconfHook, talloc, openssl ? null }:

## TODO: include ldap optionally
## TODO: include sqlite optionally
## TODO: include mysql optionally

stdenv.mkDerivation rec {
  name = "freeradius-${version}";
  version = "3.0.11";

  buildInputs = [
    autoreconfHook
    talloc
    openssl
  ];

  configureFlags = [
     "--sysconfdir=/etc"
     "--localstatedir=/var"
  ];

  installFlags = [
    "sysconfdir=\${out}/etc"
    "localstatedir=\${TMPDIR}"
   ];<commit_msg>freeradius: optional dependency support, pcap and cap enabled<commit_after>{ stdenv, fetchurl, autoreconfHook, talloc
, openssl
, linkOpenssl? true
, openldap
, withLdap ? false
, sqlite
, withSqlite ? false
, libpcap
, withPcap ? true
, libcap
, withCap ? true
, libmemcached
, withMemcached ? false
, hiredis
, withRedis ? false
, libmysql
, withMysql ? false
, withJson ? false
, libyubikey
, withYubikey ? false
, collectd
, withCollectd ? false
}:

assert withSqlite -> sqlite != null;
assert withLdap -> openldap != null;
assert withPcap -> libpcap != null;
assert withCap -> libcap != null;
assert withMemcached -> libmemcached != null;
assert withRedis -> hiredis != null;
assert withMysql -> libmysql != null;
assert withYubikey -> libyubikey != null;
assert withCollectd -> collectd != null;

## TODO: include windbind optionally (via samba?)
## TODO: include oracle optionally
## TODO: include ykclient optionally

with stdenv.lib;
stdenv.mkDerivation rec {
  name = "freeradius-${version}";
  version = "3.0.11";

  buildInputs = [ autoreconfHook openssl talloc ]
    ++ optional withLdap [ openldap ]
    ++ optional withSqlite [ sqlite ]
    ++ optional withPcap [ libpcap ]
    ++ optional withCap [ libcap ]
    ++ optional withMemcached [ libmemcached ]
    ++ optional withRedis [ hiredis ]
    ++ optional withMysql [ libmysql ]
    ++ optional withJson [ pkgs."json-c" ]
    ++ optional withYubikey [ libyubikey ]
    ++ optional withCollectd [ collectd ];

  # NOTE: are the --with-{lib}-lib-dir and --with-{lib}-include-dir necessary with buildInputs ?

  configureFlags = [
     "--sysconfdir=/etc"
     "--localstatedir=/var"
  ] ++ optional (!linkOpenssl) "--with-openssl=no";

  installFlags = [
    "sysconfdir=\${out}/etc"
    "localstatedir=\${TMPDIR}"
  ];
{'fraction_non_alphanumeric': 0.13263525305410123, 'fraction_numerical': 0.0034904013961605585, 'mean_word_length': 3.708418891170431, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2997353', 'n_tokens_mistral': 786, 'n_tokens_neox': 752, 'n_words': 189}