summary refs log blame commit diff
path: root/nixos/modules/services/hardware/throttled.nix
blob: 7617c4492d7c6a9280dd3ac68cdf33809ca31fb9 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                             





                                                  





                                                                                           
                                                                   
 



                                                           

    
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.throttled;
in {
  options = {
    services.throttled = {
      enable = mkEnableOption "fix for Intel CPU throttling";

      extraConfig = mkOption {
        type = types.str;
        default = "";
        description = "Alternative configuration";
      };
    };
  };

  config = mkIf cfg.enable {
    systemd.packages = [ pkgs.throttled ];
    # The upstream package has this in Install, but that's not enough, see the NixOS manual
    systemd.services.lenovo_fix.wantedBy = [ "multi-user.target" ];

    environment.etc."lenovo_fix.conf".source =
      if cfg.extraConfig != ""
      then pkgs.writeText "lenovo_fix.conf" cfg.extraConfig
      else "${pkgs.throttled}/etc/lenovo_fix.conf";
  };
}