1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.services.hardware.pommed;
9 defaultConf = "${pkgs.pommed_light}/etc/pommed.conf.mactel";
10in
11{
12
13 options = {
14
15 services.hardware.pommed = {
16
17 enable = lib.mkOption {
18 type = lib.types.bool;
19 default = false;
20 description = ''
21 Whether to use the pommed tool to handle Apple laptop
22 keyboard hotkeys.
23 '';
24 };
25
26 configFile = lib.mkOption {
27 type = lib.types.nullOr lib.types.path;
28 default = null;
29 description = ''
30 The path to the {file}`pommed.conf` file. Leave
31 to null to use the default config file
32 ({file}`/etc/pommed.conf.mactel`). See the
33 files {file}`/etc/pommed.conf.mactel` and
34 {file}`/etc/pommed.conf.pmac` for examples to
35 build on.
36 '';
37 };
38 };
39
40 };
41
42 config = lib.mkIf cfg.enable {
43 environment.systemPackages = [
44 pkgs.polkit
45 pkgs.pommed_light
46 ];
47
48 environment.etc."pommed.conf".source =
49 if cfg.configFile == null then defaultConf else cfg.configFile;
50
51 systemd.services.pommed = {
52 description = "Pommed Apple Hotkeys Daemon";
53 wantedBy = [ "multi-user.target" ];
54 script = "${pkgs.pommed_light}/bin/pommed -f";
55 };
56 };
57}