summary refs log tree commit diff
path: root/nixos/modules/services/hardware/pommed.nix
blob: bf7d6a46a293d5212ec9f2aa91e44ffee9fff48a (plain) (blame)
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
{ config, lib, pkgs, ... }:

with lib;

let cfg = config.services.hardware.pommed;
    defaultConf = "${pkgs.pommed_light}/etc/pommed.conf.mactel";
in {

  options = {

    services.hardware.pommed = {

      enable = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Whether to use the pommed tool to handle Apple laptop
          keyboard hotkeys.
        '';
      };

      configFile = mkOption {
        type = types.nullOr types.path;
        default = null;
        description = ''
          The path to the <filename>pommed.conf</filename> file. Leave
          to null to use the default config file
          (<filename>/etc/pommed.conf.mactel</filename>). See the
          files <filename>/etc/pommed.conf.mactel</filename> and
          <filename>/etc/pommed.conf.pmac</filename> for examples to
          build on.
        '';
      };
    };

  };

  config = mkIf cfg.enable {
    environment.systemPackages = [ pkgs.polkit pkgs.pommed_light ];

    environment.etc."pommed.conf".source =
      if cfg.configFile == null then defaultConf else cfg.configFile;

    systemd.services.pommed = {
      description = "Pommed Apple Hotkeys Daemon";
      wantedBy = [ "multi-user.target" ];
      script = "${pkgs.pommed_light}/bin/pommed -f";
    };
  };
}