1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.services.thermald;
9in
10{
11 ###### interface
12 options = {
13 services.thermald = {
14 enable = lib.mkEnableOption "thermald, the temperature management daemon";
15
16 debug = lib.mkOption {
17 type = lib.types.bool;
18 default = false;
19 description = ''
20 Whether to enable debug logging.
21 '';
22 };
23
24 ignoreCpuidCheck = lib.mkOption {
25 type = lib.types.bool;
26 default = false;
27 description = "Whether to ignore the cpuid check to allow running on unsupported platforms";
28 };
29
30 configFile = lib.mkOption {
31 type = lib.types.nullOr lib.types.path;
32 default = null;
33 description = ''
34 The thermald manual configuration file.
35
36 Leave unspecified to run with the `--adaptive` flag instead which will have thermald use your computer's DPTF adaptive tables.
37
38 See `man thermald` for more information.
39 '';
40 };
41
42 package = lib.mkPackageOption pkgs "thermald" { };
43 };
44 };
45
46 ###### implementation
47 config = lib.mkIf cfg.enable {
48 services.dbus.packages = [ cfg.package ];
49
50 systemd.services.thermald = {
51 description = "Thermal Daemon Service";
52 documentation = [ "man:thermald(8)" ];
53 wantedBy = [ "multi-user.target" ];
54 serviceConfig = {
55 PrivateNetwork = true;
56 ExecStart = ''
57 ${cfg.package}/sbin/thermald \
58 --no-daemon \
59 ${lib.optionalString cfg.debug "--loglevel=debug"} \
60 ${lib.optionalString cfg.ignoreCpuidCheck "--ignore-cpuid-check"} \
61 ${if cfg.configFile != null then "--config-file ${cfg.configFile}" else "--adaptive"} \
62 --dbus-enable
63 '';
64 };
65 };
66 };
67}