summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/ttys/gpm.nix
blob: 3651da731a3d4fc8ca0673f785aa270f45b0afcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{
  config,
  lib,
  pkgs,
  ...
}:

with lib;

let

  cfg = config.services.gpm;

in

{

  ###### interface

  options = {

    services.gpm = {

      enable = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Whether to enable GPM, the General Purpose Mouse daemon,
          which enables mouse support in virtual consoles.
        '';
      };

      protocol = mkOption {
        type = types.str;
        default = "ps/2";
        description = "Mouse protocol to use.";
      };

    };

  };

  ###### implementation

  config = mkIf cfg.enable {

    systemd.services.gpm = {
      description = "Console Mouse Daemon";

      wantedBy = [ "multi-user.target" ];
      requires = [ "dev-input-mice.device" ];
      after = [ "dev-input-mice.device" ];

      serviceConfig.ExecStart = "@${pkgs.gpm}/sbin/gpm gpm -m /dev/input/mice -t ${cfg.protocol}";
      serviceConfig.Type = "forking";
      serviceConfig.PIDFile = "/run/gpm.pid";
    };

  };

}