1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9 cfg = config.programs.weylus;
10in
11{
12 options.programs.weylus = with lib.types; {
13 enable = lib.mkEnableOption "weylus, which turns your smart phone into a graphic tablet/touch screen for your computer";
14
15 openFirewall = lib.mkOption {
16 type = bool;
17 default = false;
18 description = ''
19 Open ports needed for the functionality of the program.
20 '';
21 };
22
23 users = lib.mkOption {
24 type = listOf str;
25 default = [ ];
26 description = ''
27 To enable stylus and multi-touch support, the user you're going to use must be added to this list.
28 These users can synthesize input events system-wide, even when another user is logged in - untrusted users should not be added.
29 '';
30 };
31
32 package = lib.mkPackageOption pkgs "weylus" { };
33 };
34 config = lib.mkIf cfg.enable {
35 networking.firewall = lib.mkIf cfg.openFirewall {
36 allowedTCPPorts = [
37 1701
38 9001
39 ];
40 };
41
42 hardware.uinput.enable = true;
43
44 users.groups.uinput.members = cfg.users;
45
46 environment.systemPackages = [ cfg.package ];
47 };
48}