<commit_before>{ stdenv, lib, fetchFromGitHub, makeWrapper, perl, systemd, iw, rfkill, hdparm, ethtool, inetutils
, module_init_tools, pciutils, smartmontools, x86_energy_perf_policy
, enableRDW ? false, networkmanager
}:

let version = "0.8";
in stdenv.mkDerivation {
  name = "tlp-${version}";

  src = fetchFromGitHub {
        owner = "linrunner";
        repo = "TLP";
        rev = "${version}";
        sha256 = "19fvk0xz6i2ryf41akk4jg1c4sb4rcyxdl9fr0w4lja7g76d5zww";
      };

  makeFlags = [ "DESTDIR=$(out)"
                "TLP_LIBDIR=/lib"
                "TLP_SBIN=/bin"
                "TLP_BIN=/bin"
                "TLP_NO_INIT=1"
                "TLP_NO_PMUTILS=1"
              ];

  nativeBuildInputs = [ makeWrapper ];

  buildInputs = [ perl ];

  paths = lib.makeSearchPath "bin"
          ([ iw rfkill hdparm ethtool inetutils systemd module_init_tools pciutils smartmontools
             x86_energy_perf_policy
           ]
           ++ lib.optional enableRDW networkmanager
          );

  installTargets = [ "install-tlp" ] ++ stdenv.lib.optional enableRDW "install-rdw";

  postInstall = ''
    for i in $out/bin/* $out/lib/udev/tlp-*; do
      sed -i "s,/usr/lib/,$out/lib/,g" "$i"
      wrapProgram "$i" \
        --prefix PATH : "$paths"
    done

    for i in $out/lib/udev/rules.d/*; do
      sed -i "s,RUN+=\",\\0$out,g; s,/usr/sbin,/bin,g" "$i"
    done

    for i in man/*; do
      install -D $i $out/share/man/man''${i##*.}/$(basename $i)
    done
  '' + lib.optionalString enableRDW ''
    for i in $out/etc/NetworkManager/dispatcher.d/*; do
      sed -i "s,/usr/lib/,$out/lib/,g" "$i"
      wrapProgram "$i" \
        --prefix PATH : "$paths"
    done<commit_msg>tlp: add more shell script dependencies<commit_after>{ stdenv, lib, fetchFromGitHub, makeWrapper, perl, systemd, iw, rfkill, hdparm, ethtool, inetutils
, module_init_tools, pciutils, smartmontools, x86_energy_perf_policy, gawk, gnugrep, coreutils
, enableRDW ? false, networkmanager
}:

let version = "0.8";
in stdenv.mkDerivation {
  name = "tlp-${version}";

  src = fetchFromGitHub {
        owner = "linrunner";
        repo = "TLP";
        rev = "${version}";
        sha256 = "19fvk0xz6i2ryf41akk4jg1c4sb4rcyxdl9fr0w4lja7g76d5zww";
      };

  makeFlags = [ "DESTDIR=$(out)"
                "TLP_LIBDIR=/lib"
                "TLP_SBIN=/bin"
                "TLP_BIN=/bin"
                "TLP_NO_INIT=1"
                "TLP_NO_PMUTILS=1"
              ];

  nativeBuildInputs = [ makeWrapper ];

  buildInputs = [ perl ];

  paths = lib.makeSearchPath "bin"
          ([ iw rfkill hdparm ethtool inetutils systemd module_init_tools pciutils smartmontools
             x86_energy_perf_policy gawk gnugrep coreutils
           ]
           ++ lib.optional enableRDW networkmanager
          );

  installTargets = [ "install-tlp" ] ++ stdenv.lib.optional enableRDW "install-rdw";

  postInstall = ''
    for i in $out/bin/* $out/lib/udev/tlp-*; do
      sed -i "s,/usr/lib/,$out/lib/,g" "$i"
      wrapProgram "$i" \
        --prefix PATH : "$paths"
    done

    for i in $out/lib/udev/rules.d/*; do
      sed -i "s,RUN+=\",\\0$out,g; s,/usr/sbin,/bin,g" "$i"
    done

    for i in man/*; do
      install -D $i $out/share/man/man''${i##*.}/$(basename $i)
    done
  '' + lib.optionalString enableRDW ''
    for i in $out/etc/NetworkManager/dispatcher.d/*; do
      sed -i "s,/usr/lib/,$out/lib/,g" "$i"
      wrapProgram "$i" \
        --prefix PATH : "$paths"
    done
{'fraction_non_alphanumeric': 0.1476587187589773, 'fraction_numerical': 0.017236426314277506, 'mean_word_length': 2.2849056603773583, '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': '7225606', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1296, 'n_words': 258}