1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.hardware.opentabletdriver;
9in
10{
11 meta.maintainers = with lib.maintainers; [ thiagokokada ];
12
13 options = {
14 hardware.opentabletdriver = {
15 enable = lib.mkOption {
16 default = false;
17 type = lib.types.bool;
18 description = ''
19 Enable OpenTabletDriver udev rules, user service and blacklist kernel
20 modules known to conflict with OpenTabletDriver.
21 '';
22 };
23
24 blacklistedKernelModules = lib.mkOption {
25 type = lib.types.listOf lib.types.str;
26 default = [
27 "hid-uclogic"
28 "wacom"
29 ];
30 description = ''
31 Blacklist of kernel modules known to conflict with OpenTabletDriver.
32 '';
33 };
34
35 package = lib.mkPackageOption pkgs "opentabletdriver" { };
36
37 daemon = {
38 enable = lib.mkOption {
39 default = true;
40 type = lib.types.bool;
41 description = ''
42 Whether to start OpenTabletDriver daemon as a systemd user service.
43 '';
44 };
45 };
46 };
47 };
48
49 config = lib.mkIf cfg.enable {
50 environment.systemPackages = [ cfg.package ];
51
52 services.udev.packages = [ cfg.package ];
53
54 boot.blacklistedKernelModules = cfg.blacklistedKernelModules;
55
56 systemd.user.services.opentabletdriver =
57 with pkgs;
58 lib.mkIf cfg.daemon.enable {
59 description = "Open source, cross-platform, user-mode tablet driver";
60 wantedBy = [ "graphical-session.target" ];
61 partOf = [ "graphical-session.target" ];
62
63 serviceConfig = {
64 Type = "simple";
65 ExecStart = "${cfg.package}/bin/otd-daemon";
66 Restart = "on-failure";
67 };
68 };
69 };
70}