mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 11:45:45 +03:00

After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
108 lines
2.7 KiB
Nix
108 lines
2.7 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.lirc;
|
|
in
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
services.lirc = {
|
|
|
|
enable = lib.mkEnableOption "the LIRC daemon, to receive and send infrared signals";
|
|
|
|
options = lib.mkOption {
|
|
type = lib.types.lines;
|
|
example = ''
|
|
[lircd]
|
|
nodaemon = False
|
|
'';
|
|
description = "LIRC default options described in man:lircd(8) ({file}`lirc_options.conf`)";
|
|
};
|
|
|
|
configs = lib.mkOption {
|
|
type = lib.types.listOf lib.types.lines;
|
|
description = "Configurations for lircd to load, see man:lircd.conf(5) for details ({file}`lircd.conf`)";
|
|
};
|
|
|
|
extraArguments = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [ ];
|
|
description = "Extra arguments to lircd.";
|
|
};
|
|
};
|
|
};
|
|
|
|
###### implementation
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
# Note: LIRC executables raises a warning, if lirc_options.conf do not exists
|
|
environment.etc."lirc/lirc_options.conf".text = cfg.options;
|
|
|
|
passthru.lirc.socket = "/run/lirc/lircd";
|
|
|
|
environment.systemPackages = [ pkgs.lirc ];
|
|
|
|
systemd.sockets.lircd = {
|
|
description = "LIRC daemon socket";
|
|
wantedBy = [ "sockets.target" ];
|
|
socketConfig = {
|
|
ListenStream = config.passthru.lirc.socket;
|
|
SocketUser = "lirc";
|
|
SocketMode = "0660";
|
|
};
|
|
};
|
|
|
|
systemd.services.lircd =
|
|
let
|
|
configFile = pkgs.writeText "lircd.conf" (builtins.concatStringsSep "\n" cfg.configs);
|
|
in
|
|
{
|
|
description = "LIRC daemon service";
|
|
after = [ "network.target" ];
|
|
|
|
unitConfig.Documentation = [ "man:lircd(8)" ];
|
|
|
|
serviceConfig = {
|
|
RuntimeDirectory = [
|
|
"lirc"
|
|
"lirc/lock"
|
|
];
|
|
|
|
# Service runtime directory and socket share same folder.
|
|
# Following hacks are necessary to get everything right:
|
|
|
|
# 1. prevent socket deletion during stop and restart
|
|
RuntimeDirectoryPreserve = true;
|
|
|
|
# 2. fix runtime folder owner-ship, happens when socket activation
|
|
# creates the folder
|
|
PermissionsStartOnly = true;
|
|
ExecStartPre = [
|
|
"${pkgs.coreutils}/bin/chown lirc /run/lirc/"
|
|
];
|
|
|
|
ExecStart = ''
|
|
${pkgs.lirc}/bin/lircd --nodaemon \
|
|
${lib.escapeShellArgs cfg.extraArguments} \
|
|
${configFile}
|
|
'';
|
|
User = "lirc";
|
|
};
|
|
};
|
|
|
|
users.users.lirc = {
|
|
uid = config.ids.uids.lirc;
|
|
group = "lirc";
|
|
description = "LIRC user for lircd";
|
|
};
|
|
|
|
users.groups.lirc.gid = config.ids.gids.lirc;
|
|
};
|
|
}
|