nixos-configuration/hosts/iron/services/snapcast/ledfx.nix
2025-10-14 23:18:44 +02:00

75 lines
2.2 KiB
Nix

{ pkgs, ... }:
let
interfaces = import ../../interfaces.nix;
in
{
networking.firewall.interfaces."${interfaces.lan}".allowedTCPPorts = [
8888
];
services.pipewire.extraConfig.pipewire."10-ledfx-loop" = {
"context.modules" = [
{
name = "libpipewire-module-loopback";
args = {
"audio.position" = [ "FL,FR" ];
"capture.props" = {
"media.class" = "Audio/Sink";
"node.name" = "ledfx.input";
"node.description" = "ledfx capture";
};
"playback.props" = {
"media.class" = "Audio/Source";
"node.name" = "ledfx.output";
"node.passive" = true;
};
};
}
];
};
systemd.services.snapclient-ledfx = {
enable = true;
description = "Snapcast client";
wants = [ "network.target" "sound.target" ];
after = [ "network.target" "sound.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = "yes";
ExecStart = "${pkgs.snapcast}/bin/snapclient --host 127.0.0.1 --hostID ledfx -i 2 --player pulse -s ledfx.input";
Group = "pipewire";
NoNewPrivileges = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX";
RestrictNamespaces = true;
RuntimeDirectory = "snapclient-ledfx";
};
};
systemd.services.ledfx = {
enable = true;
description = "LedFx";
wants = [ "network.target" "sound.target" "snapclient-ledfx.service" ];
after = [ "network.target" "sound.target" "snapclient-ledfx.service" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = "yes";
ExecStart = "${pkgs.ledfx}/bin/ledfx --host 0.0.0.0 -p 8888 -c %S/ledfx";
Group = "pipewire";
NoNewPrivileges = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX";
RestrictNamespaces = true;
StateDirectory = "ledfx";
StateDirectoryMode = "0755";
};
};
}