@@ -0,0 +1,54 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+
7+cfg = config.services.xserver.cmt;
8+etcPath = "X11/xorg.conf.d";
9+
10+in {
11+
12+ options = {
13+
14+ services.xserver.cmt = {
15+ enable = mkOption {
16+ type = types.bool;
17+ default = false;
18+ description = "Enable chrome multitouch input (cmt). Touchpad drivers that are configured for chromebooks.";
19+ };
20+ models = mkOption {
21+ type = types.enum [ "atlas" "banjo" "candy" "caroline" "cave" "celes" "clapper" "cyan" "daisy" "elan" "elm" "enguarde" "eve" "expresso" "falco" "gandof" "glimmer" "gnawty" "heli" "kevin" "kip" "leon" "lulu" "orco" "pbody" "peppy" "pi" "pit" "puppy" "quawks" "rambi" "samus" "snappy" "spring" "squawks" "swanky" "winky" "wolf" "auron_paine" "auron_yuna" "daisy_skate" "nyan_big" "nyan_blaze" "veyron_jaq" "veyron_jerry" "veyron_mighty" "veyron_minnie" "veyron_speedy" ];
22+ example = "banjo";
23+ description = ''
24+ Which models to enable cmt for. Enter the Code Name for your Chromebook.
25+ Code Name can be found at <link xlink:href="https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices" />.
26+ '';
27+ };
28+ }; #closes services
29+ }; #closes options
30+
31+ config = mkIf cfg.enable {
32+
33+ services.xserver.modules = [ pkgs.xf86_input_cmt ];
34+
35+ environment.etc = {
36+ "${etcPath}/40-touchpad-cmt.conf" = {
37+ source = "${pkgs.chromium-xorg-conf}/40-touchpad-cmt.conf";
38+ };
39+ "${etcPath}/50-touchpad-cmt-${cfg.models}.conf" = {
40+ source = "${pkgs.chromium-xorg-conf}/50-touchpad-cmt-${cfg.models}.conf";
41+ };
42+ "${etcPath}/60-touchpad-cmt-${cfg.models}.conf" = {
43+ source = "${pkgs.chromium-xorg-conf}/60-touchpad-cmt-${cfg.models}.conf";
44+ };
45+ };
46+
47+ assertions = [
48+ {
49+ assertion = !config.services.xserver.libinput.enable;
50+ message = "cmt and libinput are incompatible, you cannot enable both (in services.xserver).";
51+ }
52+ ];
53+ };
54+}