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.lenovo_fix.wantedBy = [ "multi-user.target" ];
25 environment.etc."lenovo_fix.conf".source =
26 if cfg.extraConfig != ""
27 then pkgs.writeText "lenovo_fix.conf" cfg.extraConfig
28 else "${pkgs.throttled}/etc/lenovo_fix.conf";
30 # Kernel 5.9 spams warnings whenever userspace writes to CPU MSRs.
31 # See https://github.com/erpalma/throttled/issues/215
33 optional (versionAtLeast config.boot.kernelPackages.kernel.version "5.9")
34 "msr.allow_writes=on";