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