forked from mirrors/nixpkgs
29027fd1e1
Using pkgs.lib on the spine of module evaluation is problematic because the pkgs argument depends on the result of module evaluation. To prevent an infinite recursion, pkgs and some of the modules are evaluated twice, which is inefficient. Using ‘with lib’ prevents this problem.
50 lines
990 B
Nix
50 lines
990 B
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
options.services.hardware.pommed = {
|
|
enable = mkOption {
|
|
default = false;
|
|
description = ''
|
|
Whether to use the pommed tool to handle Apple laptop keyboard hotkeys.
|
|
'';
|
|
};
|
|
|
|
configFile = mkOption {
|
|
default = "${pkgs.pommed}/etc/pommed.conf";
|
|
description = ''
|
|
The contents of the pommed.conf file.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf config.services.hardware.pommed.enable {
|
|
environment.systemPackages = [ pkgs.polkit ];
|
|
|
|
environment.etc = [
|
|
{ source = config.services.hardware.pommed.configFile;
|
|
target = "pommed.conf";
|
|
}
|
|
];
|
|
|
|
services.dbus.packages = [ pkgs.pommed ];
|
|
|
|
jobs.pommed = { name = "pommed";
|
|
|
|
description = "Pommed hotkey management";
|
|
|
|
startOn = "started dbus";
|
|
|
|
postStop = "rm -f /var/run/pommed.pid";
|
|
|
|
exec = "${pkgs.pommed}/bin/pommed";
|
|
|
|
daemonType = "fork";
|
|
|
|
path = [ pkgs.eject ];
|
|
};
|
|
};
|
|
}
|