Throttled failed to run

I tried to install and activate the throttled service, but when I checked it, the service failed to run. How to fix it?

× throttled.service - Stop Intel throttling
     Loaded: loaded (/etc/systemd/system/throttled.service; enabled; preset: enabled)
    Drop-In: /nix/store/r9b2m5v7zck5y1q9pdi93gpmk5br4hc5-system-units/throttled.service.d
             └─overrides.conf
     Active: failed (Result: exit-code) since Sat 2023-10-28 18:37:31 WIB; 10h ago
   Duration: 613ms
    Process: 830 ExecStart=/nix/store/cdi7pn2hpa8zbxpf2303jvbycjsd9aqn-throttled-0.10.0/bin/throttled.py (code=exited, status=1/FAILURE)
   Main PID: 830 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 243ms

Okt 28 18:37:31 nixos throttled.py[830]:     retcode = call(*popenargs, **kwargs)
Okt 28 18:37:31 nixos throttled.py[830]:   File "/nix/store/pzf6dnxg8gf04xazzjdwarm7s03cbrgz-python3-3.10.12/lib/python3.10/subprocess.py", line 345, in call
Okt 28 18:37:31 nixos throttled.py[830]:     with Popen(*popenargs, **kwargs) as p:
Okt 28 18:37:31 nixos throttled.py[830]:   File "/nix/store/pzf6dnxg8gf04xazzjdwarm7s03cbrgz-python3-3.10.12/lib/python3.10/subprocess.py", line 971, in __init__
Okt 28 18:37:31 nixos throttled.py[830]:     self._execute_child(args, executable, preexec_fn, close_fds,
Okt 28 18:37:31 nixos throttled.py[830]:   File "/nix/store/pzf6dnxg8gf04xazzjdwarm7s03cbrgz-python3-3.10.12/lib/python3.10/subprocess.py", line 1863, in _execute_child
Okt 28 18:37:31 nixos throttled.py[830]:     raise child_exception_type(errno_num, err_msg, err_filename)
Okt 28 18:37:31 nixos throttled.py[830]: FileNotFoundError: [Errno 2] No such file or directory: 'modprobe'
Okt 28 18:37:31 nixos systemd[1]: throttled.service: Main process exited, code=exited, status=1/FAILURE
Okt 28 18:37:31 nixos systemd[1]: throttled.service: Failed with result 'exit-code'.

Awkward, looks like throttled uses modprobe to load kernel modules if they’re not loaded yet. Would be much better if it just told you to enable a kernel module, that way it doesn’t add implicit assumptions about your kernel. Or at the very least handle this error.

Silly upstream issues aside, the modprobe command that this script shells out to just loads kernel modules. It probably needs to be added to the package’s environment, or the kernel module should be enabled by default if you set the option for throttled. Either way, we can look at the source code to check the args and see what module is missing.

You’ve omitted half the output, so I can’t tell for sure which line is causing this error. But since the NixOS kernel appears to by default enable the configs module, it’ll probably be msr. So just set:

boot.kernelModules = [
    "msr"
];

Probably should also fix the nixpkgs package/module so users don’t have this problem. Looks like you’re not the first one to have it either: Throttled daemon fails to start on boot · Issue #254553 · NixOS/nixpkgs · GitHub

Thanks for letting me know, I tried it and now the throttled.service works fine.