summaryrefslogtreecommitdiffstats
path: root/nixos/modules/hardware/ckb-next.nix
blob: 552eac502759273647aed221288c7e650385e0c3 (plain)
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
43
44
45
46
47
48
49
50
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.hardware.ckb-next;

in
{
  imports = [
    (lib.mkRenamedOptionModule [ "hardware" "ckb" "enable" ] [ "hardware" "ckb-next" "enable" ])
    (lib.mkRenamedOptionModule [ "hardware" "ckb" "package" ] [ "hardware" "ckb-next" "package" ])
  ];

  options.hardware.ckb-next = {
    enable = lib.mkEnableOption "the Corsair keyboard/mouse driver";

    gid = lib.mkOption {
      type = lib.types.nullOr lib.types.int;
      default = null;
      example = 100;
      description = ''
        Limit access to the ckb daemon to a particular group.
      '';
    };

    package = lib.mkPackageOption pkgs "ckb-next" { };
  };

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

    systemd.services.ckb-next = {
      description = "Corsair Keyboards and Mice Daemon";
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        ExecStart = "${cfg.package}/bin/ckb-next-daemon ${
          lib.optionalString (cfg.gid != null) "--gid=${toString cfg.gid}"
        }";
        Restart = "on-failure";
      };
    };
  };

  meta = {
    maintainers = [ ];
  };
}