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