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 (lib.mdDoc "thermald, the temperature management daemon");
13
14 debug = mkOption {
15 type = types.bool;
16 default = false;
17 description = lib.mdDoc ''
18 Whether to enable debug logging.
19 '';
20 };
21
22 configFile = mkOption {
23 type = types.nullOr types.path;
24 default = null;
25 description = lib.mdDoc "the thermald manual configuration file.";
26 };
27
28 package = mkOption {
29 type = types.package;
30 default = pkgs.thermald;
31 defaultText = literalExpression "pkgs.thermald";
32 description = lib.mdDoc "Which thermald package to use.";
33 };
34 };
35 };
36
37 ###### implementation
38 config = mkIf cfg.enable {
39 services.dbus.packages = [ cfg.package ];
40
41 systemd.services.thermald = {
42 description = "Thermal Daemon Service";
43 wantedBy = [ "multi-user.target" ];
44 serviceConfig = {
45 PrivateNetwork = true;
46 ExecStart = ''
47 ${cfg.package}/sbin/thermald \
48 --no-daemon \
49 ${optionalString cfg.debug "--loglevel=debug"} \
50 ${optionalString (cfg.configFile != null) "--config-file ${cfg.configFile}"} \
51 --dbus-enable \
52 --adaptive
53 '';
54 };
55 };
56 };
57}