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