<commit_before>{ config, lib, pkgs, ... }:

with lib;

let

cfg = config.services.tlp;

enableRDW = config.networking.networkmanager.enable;

tlp = pkgs.tlp.override {
  inherit enableRDW;
};

# XXX: We can't use writeTextFile + readFile here because it triggers
# TLP build to get the .drv (even on --dry-run).
confFile = pkgs.runCommand "tlp"
  { config = cfg.extraConfig;
    passAsFile = [ "config" ];
  }
  ''
    cat ${tlp}/etc/default/tlp > $out
    cat $configPath >> $out
  '';

in

{

  ###### interface

  options = {

    services.tlp = {

      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Whether to enable the TLP daemon.";
      };

      extraConfig = mkOption {
        type = types.str;
        default = "";
        description = "Additional configuration variables for TLP";
      };

    };

  };


  ###### implementation

  config = mkIf cfg.enable {

    systemd.services = {
      tlp = {
        description = "TLP system startup/shutdown";

        after = [ "multi-user.target" ];
        wantedBy = [ "multi-user.target" ];
        before = [ "shutdown.target" ];

        serviceConfig = {
          Type = "oneshot";
          RemainAfterExit = true;
          ExecStart = "${tlp}/bin/tlp init start";
          ExecStop = "${tlp}/bin/tlp init stop";
        };

        environment.MODULE_DIR="/run/current-system/kernel-modules/lib/modules/";
      };

      tlp-sleep = {
        description = "TLP suspend/resume";

        wantedBy = [ "sleep.target" ];
        before = [ "sleep.target" ];<commit_msg>tlp service: add restart on config change<commit_after>{ config, lib, pkgs, ... }:

with lib;

let

cfg = config.services.tlp;

enableRDW = config.networking.networkmanager.enable;

tlp = pkgs.tlp.override {
  inherit enableRDW;
};

# XXX: We can't use writeTextFile + readFile here because it triggers
# TLP build to get the .drv (even on --dry-run).
confFile = pkgs.runCommand "tlp"
  { config = cfg.extraConfig;
    passAsFile = [ "config" ];
  }
  ''
    cat ${tlp}/etc/default/tlp > $out
    cat $configPath >> $out
  '';

in

{

  ###### interface

  options = {

    services.tlp = {

      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Whether to enable the TLP daemon.";
      };

      extraConfig = mkOption {
        type = types.str;
        default = "";
        description = "Additional configuration variables for TLP";
      };

    };

  };


  ###### implementation

  config = mkIf cfg.enable {

    systemd.services = {
      tlp = {
        description = "TLP system startup/shutdown";

        after = [ "multi-user.target" ];
        wantedBy = [ "multi-user.target" ];
        before = [ "shutdown.target" ];
        restartTriggers = [ confFile ];

        serviceConfig = {
          Type = "oneshot";
          RemainAfterExit = true;
          ExecStart = "${tlp}/bin/tlp init start";
          ExecStop = "${tlp}/bin/tlp init stop";
        };

        environment.MODULE_DIR="/run/current-system/kernel-modules/lib/modules/";
      };

      tlp-sleep = {
        description = "TLP suspend/resume";

        wantedBy = [ "sleep.target" ];
        before = [ "sleep.target" ];
{'fraction_non_alphanumeric': 0.14017252002464572, 'fraction_numerical': 0.0, 'mean_word_length': 2.0923809523809522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6257134', 'n_tokens_mistral': 1049, 'n_tokens_neox': 1002, 'n_words': 234}