<commit_before>{ stdenv, fetchFromGitHub
, withMySQL ? true, withPSQL ? false, withSQLite ? false
, mysql, postgresql, sqlite, gawk
, lib
}:

stdenv.mkDerivation rec {
  pname = "shmig";
  version = "1.0.0";

  src = fetchFromGitHub {
    owner = "mbucc";
    repo = "shmig";
    rev = "v${version}";
    sha256 = "15ry1d51d6dlzzzhck2x57wrq48vs4n9pp20bv2sz6nk92fva5l5";
  };

  makeFlags = [ "PREFIX=$(out)" ];

  postPatch = ''
    patchShebangs .

    substituteInPlace shmig \
      --replace "\`which mysql\`" "${lib.optionalString withMySQL "${mysql.client}/bin/mysql"}" \
      --replace "\`which psql\`" "${lib.optionalString withPSQL "${postgresql}/bin/psql"}" \
      --replace "\`which sqlite3\`" "${lib.optionalString withSQLite "${sqlite}/bin/sqlite3"}" \
      --replace "awk" "${gawk}/bin/awk"
  '';<commit_msg>shmig: fix `migrate` command when postgres is enabled<commit_after>{ stdenv, fetchFromGitHub
, withMySQL ? true, withPSQL ? false, withSQLite ? false
, mysql, postgresql, sqlite, gawk, gnugrep, findutils, gnused
, lib
}:

stdenv.mkDerivation rec {
  pname = "shmig";
  version = "1.0.0";

  src = fetchFromGitHub {
    owner = "mbucc";
    repo = "shmig";
    rev = "v${version}";
    sha256 = "15ry1d51d6dlzzzhck2x57wrq48vs4n9pp20bv2sz6nk92fva5l5";
  };

  makeFlags = [ "PREFIX=$(out)" ];

  postPatch = ''
    patchShebangs .

    substituteInPlace shmig \
      --replace "\`which mysql\`" "${lib.optionalString withMySQL "${mysql.client}/bin/mysql"}" \
      --replace "\`which psql\`" "${lib.optionalString withPSQL "${postgresql}/bin/psql"}" \
      --replace "\`which sqlite3\`" "${lib.optionalString withSQLite "${sqlite}/bin/sqlite3"}" \
      --replace "awk" "${gawk}/bin/awk" \
      --replace "grep" "${gnugrep}/bin/grep" \
      --replace "find" "${findutils}/bin/find" \
      --replace "sed" "${gnused}/bin/sed"
  '';
{'fraction_non_alphanumeric': 0.18299246501614638, 'fraction_numerical': 0.031216361679224973, 'mean_word_length': 3.363849765258216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2361457', 'n_tokens_mistral': 736, 'n_tokens_neox': 700, 'n_words': 133}