summary refs log tree commit diff
path: root/nixos/modules/services/hardware/supergfxd.nix
blob: bd82775e824613d6cf2c2a9d439709f8a8183f79 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ config, lib, pkgs, ... }:

let
  cfg = config.services.supergfxd;
  json = pkgs.formats.json { };
in
{
  options = {
    services.supergfxd = {
      enable = lib.mkEnableOption (lib.mdDoc "Enable the supergfxd service");

      settings = lib.mkOption {
        type = lib.types.nullOr json.type;
        default = null;
        description = lib.mdDoc ''
          The content of /etc/supergfxd.conf.
          See https://gitlab.com/asus-linux/supergfxctl/#config-options-etcsupergfxdconf.
        '';
      };
    };
  };

  config = lib.mkIf cfg.enable {
    environment.systemPackages = [ pkgs.supergfxctl ];

    environment.etc."supergfxd.conf" = lib.mkIf (cfg.settings != null) {
      source = json.generate "supergfxd.conf" cfg.settings;
      mode = "0644";
    };

    services.dbus.enable = true;

    systemd.packages = [ pkgs.supergfxctl ];
    systemd.services.supergfxd.wantedBy = [ "multi-user.target" ];
    systemd.services.supergfxd.path = [ pkgs.kmod pkgs.pciutils ];

    services.dbus.packages = [ pkgs.supergfxctl ];
    services.udev.packages = [ pkgs.supergfxctl ];
  };

  meta.maintainers = pkgs.supergfxctl.meta.maintainers;
}