1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8with lib;
9
10let
11
12 cfg = config.services.gpm;
13
14in
15
16{
17
18 ###### interface
19
20 options = {
21
22 services.gpm = {
23
24 enable = mkOption {
25 type = types.bool;
26 default = false;
27 description = ''
28 Whether to enable GPM, the General Purpose Mouse daemon,
29 which enables mouse support in virtual consoles.
30 '';
31 };
32
33 protocol = mkOption {
34 type = types.str;
35 default = "ps/2";
36 description = "Mouse protocol to use.";
37 };
38
39 };
40
41 };
42
43 ###### implementation
44
45 config = mkIf cfg.enable {
46
47 systemd.services.gpm = {
48 description = "Console Mouse Daemon";
49
50 wantedBy = [ "multi-user.target" ];
51 requires = [ "dev-input-mice.device" ];
52 after = [ "dev-input-mice.device" ];
53
54 serviceConfig.ExecStart = "@${pkgs.gpm}/sbin/gpm gpm -m /dev/input/mice -t ${cfg.protocol}";
55 serviceConfig.Type = "forking";
56 serviceConfig.PIDFile = "/run/gpm.pid";
57 };
58
59 };
60
61}