<commit_before>{ stdenv, lib, fetchFromGitHub
, parted, systemd ? null
}:

stdenv.mkDerivation rec {
  pname = "f3";
  version = "8.0";

  src = fetchFromGitHub {
    owner = "AltraMayor";
    repo = pname;
    rev = "v${version}";
    sha256 = "17l5vspfcgfbkqg7bakp3gql29yb05gzawm8n3im30ilzdr53678";
  };

  postPatch = ''
     sed -i 's/-oroot -groot//' Makefile

     for f in f3write.h2w log-f3wr; do
      substituteInPlace $f \
        --replace '$(dirname $0)' $out/bin
     done
  '';

  buildInputs = [
    parted
  ]
  ++ lib.optional stdenv.isLinux systemd;

  enableParallelBuilding = true;

  buildFlags   = [
    "all" # f3read, f3write
  ]
  ++ lib.optional stdenv.isLinux "extra"; # f3brew, f3fix, f3probe

  installFlags = [
    "PREFIX=${placeholder "out"}"
  ];

  installTargets = [
    "install"
  ]
  ++ lib.optional stdenv.isLinux "install-extra";

  postInstall = ''<commit_msg>f3: fix build on darwin<commit_after>{ stdenv, lib, fetchFromGitHub
, parted, systemd, argp-standalone
}:

stdenv.mkDerivation rec {
  pname = "f3";
  version = "8.0";

  src = fetchFromGitHub {
    owner = "AltraMayor";
    repo = pname;
    rev = "v${version}";
    sha256 = "17l5vspfcgfbkqg7bakp3gql29yb05gzawm8n3im30ilzdr53678";
  };

  postPatch = ''
     sed -i 's/-oroot -groot//' Makefile

     for f in f3write.h2w log-f3wr; do
      substituteInPlace $f \
        --replace '$(dirname $0)' $out/bin
     done
  '';

  buildInputs = lib.optional stdenv.isLinux [ systemd parted ]
  ++ lib.optional stdenv.isDarwin [ argp-standalone ];

  enableParallelBuilding = true;

  buildFlags   = [
    "all" # f3read, f3write
  ]
  ++ lib.optional stdenv.isLinux "extra"; # f3brew, f3fix, f3probe

  installFlags = [
    "PREFIX=${placeholder "out"}"
  ];

  installTargets = [
    "install"
  ]
  ++ lib.optional stdenv.isLinux "install-extra";

  postInstall = ''
{'fraction_non_alphanumeric': 0.1397964649169791, 'fraction_numerical': 0.035886448848419926, 'mean_word_length': 2.8997912317327765, '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': '5985340', 'n_tokens_mistral': 781, 'n_tokens_neox': 732, 'n_words': 143}