ctucx.git: nixfiles

ctucx' nixfiles

commit 86793f34881ca41c5f72f151798a90d4119bb2b2
parent 929cbf4a4ebd5bb79c3d5d52ef7d99e1b60d2100
Author: Leah (ctucx) <leah@ctu.cx>
Date: Wed, 12 Jan 2022 19:22:21 +0100

programs/pipewire: update config
1 file changed, 55 insertions(+), 5 deletions(-)
M
configurations/programs/pipewire.nix
|
60
+++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
diff --git a/configurations/programs/pipewire.nix b/configurations/programs/pipewire.nix
@@ -1,11 +1,18 @@
-{ ... }:
+{ config, ib, ... }:
 
 {
-  security.rtkit.enable = true;
   imports = [
     ./avahi.nix
   ];
 
+  security.rtkit.enable  = true;
+  networking.firewall    = {
+    extraCommands   = (if config.networking.hostName == "stasicontainer" then ''
+      iptables -A nixos-fw -m iprange --src-range 10.0.0.0-10.0.0.255 -p tcp --dport 4713 -j nixos-fw-accept
+      iptables -A nixos-fw -m iprange --src-range 195.39.246.32-195.39.246.47 -p tcp --dport 4713 -j nixos-fw-accept
+    '' else "");
+  };
+
   services = {
     pipewire = {
       enable = true;

@@ -13,10 +20,53 @@
 
       media-session.enable = true;
       alsa.enable          = true;
+      pulse.enable         = true;
 
-      #todo: discovery of pulseaudio-network-shares
-      pulse = {
-        enable = true;
+      config = {
+        pipewire-pulse = {
+          "context.exec"       = [];
+          "stream.properties"  = {};
+          "context.properties" = {};
+          "context.spa-libs"   = {
+            "audio.convert.*" = "audioconvert/libspa-audioconvert";
+            "support.*"       = "support/libspa-support";
+          };
+          "context.modules" = [
+            {
+              name  = "libpipewire-module-rtkit";
+              args  = {};
+              flags = [ "ifexists" "nofail" ];
+            }
+            { name = "libpipewire-module-protocol-native"; }
+            { name = "libpipewire-module-client-node"; }
+            { name = "libpipewire-module-adapter"; }
+            { name = "libpipewire-module-metadata"; }
+            {
+              name = "libpipewire-module-protocol-pulse";
+              args = {
+                "server.address" = (
+                  if config.networking.hostName != "stasicontainer" then [
+                    "unix:native"
+                  ] else [
+                    "unix:native"
+                    "tcp:4713"
+                  ]
+                );
+                "vm.overrides" = {
+                  "pulse.min.quantum" = "1024/48000";
+                };
+              };
+            }
+            { name = "libpipewire-module-zeroconf-discover"; }
+          ] ++ (if config.networking.hostName == "stasicontainer" then [
+            {
+              name = "libpipewire-module-pulse-tunnel";
+              args = {
+                "pulse.server.address" = "tcp:10.0.0.1";
+              };
+            }
+          ] else []);
+        };
       };
     };
   };