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