1{ config, lib, pkgs, ... }:
2
3let
4 cfg = config.services.iptsd;
5 format = pkgs.formats.ini { };
6 configFile = format.generate "iptsd.conf" cfg.config;
7in {
8 options.services.iptsd = {
9 enable = lib.mkEnableOption "the userspace daemon for Intel Precise Touch & Stylus";
10
11 config = lib.mkOption {
12 default = { };
13 description = ''
14 Configuration for IPTSD. See the
15 [reference configuration](https://github.com/linux-surface/iptsd/blob/master/etc/iptsd.conf)
16 for available options and defaults.
17 '';
18 type = lib.types.submodule {
19 freeformType = format.type;
20 options = {
21 Touch = {
22 DisableOnPalm = lib.mkOption {
23 default = false;
24 description = "Ignore all touch inputs if a palm was registered on the display.";
25 type = lib.types.bool;
26 };
27 DisableOnStylus = lib.mkOption {
28 default = false;
29 description = "Ignore all touch inputs if a stylus is in proximity.";
30 type = lib.types.bool;
31 };
32 };
33 Stylus = {
34 Disable = lib.mkOption {
35 default = false;
36 description = "Disables the stylus. No stylus data will be processed.";
37 type = lib.types.bool;
38 };
39 };
40 };
41 };
42 };
43 };
44
45 config = lib.mkIf cfg.enable {
46 systemd.packages = [ pkgs.iptsd ];
47 environment.etc."iptsd.conf".source = configFile;
48 systemd.services."iptsd@".restartTriggers = [ configFile ];
49 services.udev.packages = [ pkgs.iptsd ];
50 };
51
52 meta.maintainers = with lib.maintainers; [ dotlambda ];
53}