<commit_before>{ stdenv, fetchurl, pkgconfig, systemd, utillinux, coreutils, nettools, man
, enableCgiScripts ? true, gd
}:

assert enableCgiScripts -> gd != null;

stdenv.mkDerivation rec {
  pname = "apcupsd";
  name = "${pname}-3.14.14";

  src = fetchurl {
    url = "mirror://sourceforge/${pname}/${name}.tar.gz";
    sha256 = "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv";
  };

  buildInputs = [ pkgconfig utillinux man ] ++ stdenv.lib.optional enableCgiScripts gd;

  # ./configure ignores --prefix, so we must specify some paths manually
  # There is no real reason for a bin/sbin split, so just use bin.
  preConfigure = ''
    export ac_cv_path_SHUTDOWN=${systemd}/sbin/shutdown
    export ac_cv_path_WALL=${utillinux}/bin/wall
    sed -i 's|/bin/cat|${coreutils}/bin/cat|' configure
    export configureFlags="\
        --bindir=$out/bin \<commit_msg>apcupsd: unbreak build<commit_after>{ stdenv, fetchurl, pkgconfig, systemd, utillinux, coreutils, nettools, man
, enableCgiScripts ? true, gd
}:

assert enableCgiScripts -> gd != null;

stdenv.mkDerivation rec {
  pname = "apcupsd";
  name = "${pname}-3.14.14";

  src = fetchurl {
    url = "mirror://sourceforge/${pname}/${name}.tar.gz";
    sha256 = "0rwqiyzlg9p0szf3x6q1ppvrw6f6dbpn2rc5z623fk3bkdalhxyv";
  };

  buildInputs = [ pkgconfig utillinux man ] ++ stdenv.lib.optional enableCgiScripts gd;

  prePatch = ''
    sed -e "s,\$(INSTALL_PROGRAM) \$(STRIP),\$(INSTALL_PROGRAM)," \
        -i ./src/apcagent/Makefile ./autoconf/targets.mak
  '';

  # ./configure ignores --prefix, so we must specify some paths manually
  # There is no real reason for a bin/sbin split, so just use bin.
  preConfigure = ''
    export ac_cv_path_SHUTDOWN=${systemd}/sbin/shutdown
    export ac_cv_path_WALL=${utillinux}/bin/wall
    sed -i 's|/bin/cat|${coreutils}/bin/cat|' configure
    export configureFlags="\
        --bindir=$out/bin \
{'fraction_non_alphanumeric': 0.14143007360672977, 'fraction_numerical': 0.023133543638275498, 'mean_word_length': 3.7575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4764316', 'n_tokens_mistral': 753, 'n_tokens_neox': 713, 'n_words': 150}