1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8with lib;
9
10let
11
12 cfg = config.services.xserver.cmt;
13 etcPath = "X11/xorg.conf.d";
14
15in
16{
17
18 options = {
19
20 services.xserver.cmt = {
21 enable = mkOption {
22 type = types.bool;
23 default = false;
24 description = "Enable chrome multitouch input (cmt). Touchpad drivers that are configured for chromebooks.";
25 };
26 models = mkOption {
27 type = types.enum [
28 "atlas"
29 "banjo"
30 "candy"
31 "caroline"
32 "cave"
33 "celes"
34 "clapper"
35 "cyan"
36 "daisy"
37 "elan"
38 "elm"
39 "enguarde"
40 "eve"
41 "expresso"
42 "falco"
43 "gandof"
44 "glimmer"
45 "gnawty"
46 "heli"
47 "kevin"
48 "kip"
49 "leon"
50 "lulu"
51 "orco"
52 "pbody"
53 "peppy"
54 "pi"
55 "pit"
56 "puppy"
57 "quawks"
58 "rambi"
59 "samus"
60 "snappy"
61 "spring"
62 "squawks"
63 "swanky"
64 "winky"
65 "wolf"
66 "auron_paine"
67 "auron_yuna"
68 "daisy_skate"
69 "nyan_big"
70 "nyan_blaze"
71 "veyron_jaq"
72 "veyron_jerry"
73 "veyron_mighty"
74 "veyron_minnie"
75 "veyron_speedy"
76 ];
77 example = "banjo";
78 description = ''
79 Which models to enable cmt for. Enter the Code Name for your Chromebook.
80 Code Name can be found at <https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices>.
81 '';
82 };
83 }; # closes services
84 }; # closes options
85
86 config = mkIf cfg.enable {
87
88 services.xserver.modules = [ pkgs.xf86_input_cmt ];
89
90 environment.etc = {
91 "${etcPath}/40-touchpad-cmt.conf" = {
92 source = "${pkgs.chromium-xorg-conf}/40-touchpad-cmt.conf";
93 };
94 "${etcPath}/50-touchpad-cmt-${cfg.models}.conf" = {
95 source = "${pkgs.chromium-xorg-conf}/50-touchpad-cmt-${cfg.models}.conf";
96 };
97 "${etcPath}/60-touchpad-cmt-${cfg.models}.conf" = {
98 source = "${pkgs.chromium-xorg-conf}/60-touchpad-cmt-${cfg.models}.conf";
99 };
100 };
101
102 assertions = [
103 {
104 assertion = !config.services.libinput.enable;
105 message = ''
106 cmt and libinput are incompatible, meaning you cannot enable them both.
107 To use cmt you need to disable libinput with `services.libinput.enable = false`
108 If you haven't enabled it in configuration.nix, it's enabled by default on a
109 different xserver module.
110 '';
111 }
112 ];
113 };
114}