PJ/nix/cec.nix

33 lines
846 B
Nix

{ pkgs, ... }:
{
boot.kernelModules = [ "cec" ];
environment.systemPackages = with pkgs; [
libcec
];
services.udev.extraRules = ''
# Pulse-Eight CEC adapter
SUBSYSTEM=="tty" ACTION=="add" ATTRS{manufacturer}=="Pulse-Eight" ATTRS{product}=="CEC Adapter" GROUP="video" MODE="0660"
'';
systemd.sockets."cec-client" = {
wantedBy = [ "sockets.target" ];
socketConfig = {
ListenFIFO = "/run/cec.fifo";
SocketGroup = "video";
SocketMode = "0660";
};
};
systemd.services."cec-client" = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = ''${pkgs.libcec}/bin/cec-client -d 1 -o /dev/ttyACM0'';
ExecStop = ''/bin/sh -c "echo q > /run/cec.fifo"'';
StandardInput = "socket";
StandardOutput = "journal";
Restart = "on-failure";
};
};
}