1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9 cfg = config.services.supergfxd;
10 json = pkgs.formats.json { };
11in
12{
13 options = {
14 services.supergfxd = {
15 enable = lib.mkEnableOption "the supergfxd service";
16
17 settings = lib.mkOption {
18 type = lib.types.nullOr json.type;
19 default = null;
20 description = ''
21 The content of /etc/supergfxd.conf.
22 See <https://gitlab.com/asus-linux/supergfxctl/#config-options-etcsupergfxdconf>.
23 '';
24 };
25 };
26 };
27
28 config = lib.mkIf cfg.enable {
29 environment.systemPackages = [ pkgs.supergfxctl ];
30
31 environment.etc."supergfxd.conf" = lib.mkIf (cfg.settings != null) {
32 source = json.generate "supergfxd.conf" cfg.settings;
33 mode = "0644";
34 };
35
36 services.dbus.enable = true;
37
38 systemd.packages = [ pkgs.supergfxctl ];
39 systemd.services.supergfxd.wantedBy = [ "multi-user.target" ];
40 systemd.services.supergfxd.path = [
41 pkgs.kmod
42 pkgs.pciutils
43 ];
44
45 services.dbus.packages = [ pkgs.supergfxctl ];
46 services.udev.packages = [ pkgs.supergfxctl ];
47 };
48
49 meta.maintainers = pkgs.supergfxctl.meta.maintainers;
50}