git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #32045 from ck3d/nixos-lirc

initial NixOS module for LIRC

commitf456d7f57533ec96938f99c4af3f24e3ed8c441b authorPeter Hoeg <peter@hoeg.com> dateMon 17 Sep 2018, 11:35 (8 years ago) parent3904016533efd0
3 files changed+88
nixos/modules/misc/ids.nix+2 nixos/modules/module-list.nix+1 nixos/modules/services/hardware/lirc.nix+85
nixos/modules/misc/ids.nix+2
@@ -329,6 +329,7 @@
329329 # kvm = 302; # unused
330330 # render = 303; # unused
331331 zeronet = 304;
332+ lirc = 305;
332333
333334 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
334335
@@ -618,6 +619,7 @@
618619 kvm = 302; # default udev rules from systemd requires these
619620 render = 303; # default udev rules from systemd requires these
620621 zeronet = 304;
622+ lirc = 305;
621623
622624 # When adding a gid, make sure it doesn't match an existing
623625 # uid. Users and groups with the same name should have equal
nixos/modules/module-list.nix+1
@@ -272,6 +272,7 @@
272272 ./services/hardware/interception-tools.nix
273273 ./services/hardware/irqbalance.nix
274274 ./services/hardware/lcd.nix
275+ ./services/hardware/lirc.nix
275276 ./services/hardware/nvidia-optimus.nix
276277 ./services/hardware/pcscd.nix
277278 ./services/hardware/pommed.nix
nixos/modules/services/hardware/lirc.nixnew file+85
@@ -0,0 +1,85 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.lirc;
7+in {
8+
9+ ###### interface
10+
11+ options = {
12+ services.lirc = {
13+
14+ enable = mkEnableOption "LIRC daemon";
15+
16+ options = mkOption {
17+ type = types.lines;
18+ example = ''
19+ [lircd]
20+ nodaemon = False
21+ '';
22+ description = "LIRC default options descriped in man:lircd(8) (<filename>lirc_options.conf</filename>)";
23+ };
24+
25+ configs = mkOption {
26+ type = types.listOf types.lines;
27+ description = "Configurations for lircd to load, see man:lircd.conf(5) for details (<filename>lircd.conf</filename>)";
28+ };
29+
30+ extraArguments = mkOption {
31+ type = types.listOf types.str;
32+ default = [];
33+ description = "Extra arguments to lircd.";
34+ };
35+
36+ };
37+ };
38+
39+ ###### implementation
40+
41+ config = mkIf cfg.enable {
42+
43+ # Note: LIRC executables raises a warning, if lirc_options.conf do not exists
44+ environment.etc."lirc/lirc_options.conf".text = cfg.options;
45+
46+ environment.systemPackages = [ pkgs.lirc ];
47+
48+ systemd.sockets.lircd = {
49+ description = "LIRC daemon socket";
50+ wantedBy = [ "sockets.target" ];
51+ socketConfig = {
52+ ListenStream = "/run/lirc/lircd";
53+ SocketUser = "lirc";
54+ SocketMode = "0660";
55+ };
56+ };
57+
58+ systemd.services.lircd = let
59+ configFile = pkgs.writeText "lircd.conf" (builtins.concatStringsSep "\n" cfg.configs);
60+ in {
61+ description = "LIRC daemon service";
62+ after = [ "network.target" ];
63+
64+ unitConfig.Documentation = [ "man:lircd(8)" ];
65+
66+ serviceConfig = {
67+ RuntimeDirectory = "lirc";
68+ ExecStart = ''
69+ ${pkgs.lirc}/bin/lircd --nodaemon \
70+ ${escapeShellArgs cfg.extraArguments} \
71+ ${configFile}
72+ '';
73+ User = "lirc";
74+ };
75+ };
76+
77+ users.users.lirc = {
78+ uid = config.ids.uids.lirc;
79+ group = "lirc";
80+ description = "LIRC user for lircd";
81+ };
82+
83+ users.groups.lirc.gid = config.ids.gids.lirc;
84+ };
85+}