1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.cpupower-gui;
7in {
8 options = {
9 services.cpupower-gui = {
10 enable = mkOption {
11 type = lib.types.bool;
12 default = false;
13 example = true;
14 description = lib.mdDoc ''
15 Enables dbus/systemd service needed by cpupower-gui.
16 These services are responsible for retrieving and modifying cpu power
17 saving settings.
18 '';
19 };
20 };
21 };
22
23 config = mkIf cfg.enable {
24 environment.systemPackages = [ pkgs.cpupower-gui ];
25 services.dbus.packages = [ pkgs.cpupower-gui ];
26 systemd.user = {
27 services.cpupower-gui-user = {
28 description = "Apply cpupower-gui config at user login";
29 wantedBy = [ "graphical-session.target" ];
30 serviceConfig = {
31 Type = "oneshot";
32 ExecStart = "${pkgs.cpupower-gui}/bin/cpupower-gui config";
33 };
34 };
35 };
36 systemd.services = {
37 cpupower-gui = {
38 description = "Apply cpupower-gui config at boot";
39 wantedBy = [ "multi-user.target" ];
40 serviceConfig = {
41 Type = "oneshot";
42 ExecStart = "${pkgs.cpupower-gui}/bin/cpupower-gui config";
43 };
44 };
45 cpupower-gui-helper = {
46 description = "cpupower-gui system helper";
47 aliases = [ "dbus-org.rnd2.cpupower_gui.helper.service" ];
48 serviceConfig = {
49 Type = "dbus";
50 BusName = "org.rnd2.cpupower_gui.helper";
51 ExecStart = "${pkgs.cpupower-gui}/lib/cpupower-gui/cpupower-gui-helper";
52 };
53 };
54 };
55 };
56}