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