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