ctucx.git: nixfiles

ctucx' nixfiles

commit 30014e2a36562dd16db612e9865926a14c04c455
parent ad3abbee5dbb12e6e819fe6f0d958e9de475c208
Author: Leah (ctucx) <leah@ctu.cx>
Date: Wed, 19 Jan 2022 12:34:01 +0100

programs/pipewire: reliably load tunnel-module on stasicontainer
1 file changed, 34 insertions(+), 10 deletions(-)
M
configurations/programs/pipewire.nix
|
44
++++++++++++++++++++++++++++++++++----------
diff --git a/configurations/programs/pipewire.nix b/configurations/programs/pipewire.nix
@@ -1,4 +1,4 @@
-{ config, ib, ... }:
+{ config, lib, pkgs, ... }:
 
 {
   imports = [

@@ -58,17 +58,41 @@
               };
             }
             { 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";
-                "tunnel.mode"          = "playback";
-              };
-            }
-          ] else []);
+          ];
+
+#          ] ++ (if config.networking.hostName == "stasicontainer" then [
+#            {
+#              name = "libpipewire-module-pulse-tunnel";
+#              args = {
+#                "pulse.server.address" = "tcp:10.0.0.1";
+#                "tunnel.mode"          = "playback";
+#              };
+#            }
+#          ] else []);
         };
       };
     };
   };
+
+  home-manager.users.leah.systemd.user.services = lib.mkIf (config.networking.hostName == "stasicontainer") {
+    pipewire-pulse-tunnel = {
+      Unit = {
+        Requires = [ "pipewire-pulse.service" ];
+        After    = [ "pipewire-pulse.service" "network-online.target" ];
+        BindsTo  = [ "pipewire-pulse.service" ];
+      };
+
+      Service = {
+        Type            = "oneshot";
+        RemainAfterExit = true;
+        ExecStartPre    = "/usr/bin/env sh -c 'until ping -c1 195.39.246.41; do sleep 0.1; done;'";
+        ExecStart       = "${pkgs.pulseaudio}/bin/pactl load-module module-tunnel-sink server=195.39.246.41";
+        ExecStop        = "${pkgs.pulseaudio}/bin/pactl unload-module module-tunnel-sink";
+      };
+
+      Install = {
+        WantedBy = [ "pipewire-pulse.service" ];
+      };
+    };
+  };
 }