1 { config, lib, pkgs, ... }:
6 cfg = config.services.throttled;
10 enable = mkEnableOption (lib.mdDoc "fix for Intel CPU throttling");
12 extraConfig = mkOption {
15 description = lib.mdDoc "Alternative configuration";
20 config = mkIf cfg.enable {
21 systemd.packages = [ pkgs.throttled ];
22 # The upstream package has this in Install, but that's not enough, see the NixOS manual
23 systemd.services.throttled.wantedBy = [ "multi-user.target" ];
25 environment.etc."throttled.conf".source =
26 if cfg.extraConfig != ""
27 then pkgs.writeText "throttled.conf" cfg.extraConfig
28 else "${pkgs.throttled}/etc/throttled.conf";
30 hardware.cpu.x86.msr.enable = true;
31 # Kernel 5.9 spams warnings whenever userspace writes to CPU MSRs.
32 # See https://github.com/erpalma/throttled/issues/215
33 hardware.cpu.x86.msr.settings.allow-writes =
34 mkIf (versionAtLeast config.boot.kernelPackages.kernel.version "5.9") "on";