[RFC PATCH] Run PipeWire and WirePlumber in the VMs

Demi Marie Obenour
2025-06-17T15:30:29Z

[-- Attachment #1.1.1: Type: text/plain, Size: 7746 bytes --]

WirePlumber is completely overkill as a session manager here, and
ideally a trivial session manager would be used instead. Also, this
code has seen absolutely no testing beyond "it builds", not least
because there is no way to add a virtio-sound device to Cloud Hypervisor
yet and I haven't tried using QEMU TCG.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
---
img/app/default.nix | 5 ++++-
img/app/etc/fstab | 5 +++--
.../etc/s6-rc/app/dependencies.d/wireplumber | 0
img/app/etc/s6-rc/directories/type | 1 +
img/app/etc/s6-rc/directories/up | 11 ++++++++++
.../s6-rc/pipewire/dependencies.d/directories | 0
img/app/etc/s6-rc/pipewire/notification-fd | 1 +
img/app/etc/s6-rc/pipewire/run | 20 +++++++++++++++++++
img/app/etc/s6-rc/pipewire/type | 1 +
.../dependencies.d/directories | 0
img/app/etc/s6-rc/wayland-proxy-virtwl/run | 11 ----------
.../etc/s6-rc/wireplumber/dependencies.d/dbus | 0
.../s6-rc/wireplumber/dependencies.d/pipewire | 0
img/app/etc/s6-rc/wireplumber/run | 16 +++++++++++++++
img/app/etc/s6-rc/wireplumber/type | 1 +
15 files changed, 58 insertions(+), 14 deletions(-)
create mode 100644 img/app/etc/s6-rc/app/dependencies.d/wireplumber
create mode 100644 img/app/etc/s6-rc/directories/type
create mode 100644 img/app/etc/s6-rc/directories/up
create mode 100644 img/app/etc/s6-rc/pipewire/dependencies.d/directories
create mode 100644 img/app/etc/s6-rc/pipewire/notification-fd
create mode 100644 img/app/etc/s6-rc/pipewire/run
create mode 100644 img/app/etc/s6-rc/pipewire/type
create mode 100644 img/app/etc/s6-rc/wayland-proxy-virtwl/dependencies.d/directories
create mode 100644 img/app/etc/s6-rc/wireplumber/dependencies.d/dbus
create mode 100644 img/app/etc/s6-rc/wireplumber/dependencies.d/pipewire
create mode 100644 img/app/etc/s6-rc/wireplumber/run
create mode 100644 img/app/etc/s6-rc/wireplumber/type

diff --git a/img/app/default.nix b/img/app/default.nix
index a196205..32ddb67 100644
--- a/img/app/default.nix
+++ b/img/app/default.nix
@@ -8,7 +8,7 @@ pkgsStatic.callPackage (
{ lib, stdenvNoCC, runCommand, writeClosure
, erofs-utils, jq, s6-rc, util-linux
, busybox, cacert, dejavu_fonts, execline, kmod, linux_latest, mdevd, s6
-, s6-linux-init, xdg-desktop-portal-spectrum,
+, s6-linux-init, xdg-desktop-portal-spectrum
}:

let
@@ -48,6 +48,9 @@ let
pkgs.xwayland
pkgs.xdg-desktop-portal
pkgs.xdg-desktop-portal-gtk
+ # Depends on pulseaudio libs
+ pkgs.pipewire
+ pkgs.wireplumber
];
})).fhsenv;
in
diff --git a/img/app/etc/fstab b/img/app/etc/fstab
index a95088b..40aa3bd 100644
--- a/img/app/etc/fstab
+++ b/img/app/etc/fstab
@@ -1,7 +1,8 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2020-2022 Alyssa Ross <hi@alyssa.is>
proc /proc proc defaults 0 0
-devpts /dev/pts devpts defaults,gid=4,mode=620 0 0
+devpts /dev/pts devpts defaults,gid=4,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
-tmpfs /tmp tmpfs defaults 0 0
+tmpfs /tmp tmpfs defaults,mode=1755 0 0
+tmpfs /run tmpfs defaults 0 0
diff --git a/img/app/etc/s6-rc/app/dependencies.d/wireplumber b/img/app/etc/s6-rc/app/dependencies.d/wireplumber
new file mode 100644
index 0000000..e69de29
diff --git a/img/app/etc/s6-rc/directories/type b/img/app/etc/s6-rc/directories/type
new file mode 100644
index 0000000..bdd22a1
--- /dev/null
+++ b/img/app/etc/s6-rc/directories/type
@@ -0,0 +1 @@
+oneshot
diff --git a/img/app/etc/s6-rc/directories/up b/img/app/etc/s6-rc/directories/up
new file mode 100644
index 0000000..2396fad
--- /dev/null
+++ b/img/app/etc/s6-rc/directories/up
@@ -0,0 +1,11 @@
+#!/bin/execlineb -P
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2023-2024 Alyssa Ross <hi@alyssa.is>
+#
+# Directory creation (if it's copyrightable):
+# SPDX-License-Identifier: MIT
+# SPDX-FileCopyrightText: 2022 Unikie
+
+if { mkdir -m 1755 /tmp/.X11-unix }
+if { mkdir -m 0755 /run/user }
+if { mkdir -m 0700 /run/user/0 }
diff --git a/img/app/etc/s6-rc/pipewire/dependencies.d/directories b/img/app/etc/s6-rc/pipewire/dependencies.d/directories
new file mode 100644
index 0000000..e69de29
diff --git a/img/app/etc/s6-rc/pipewire/notification-fd b/img/app/etc/s6-rc/pipewire/notification-fd
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/img/app/etc/s6-rc/pipewire/notification-fd
@@ -0,0 +1 @@
+5
diff --git a/img/app/etc/s6-rc/pipewire/run b/img/app/etc/s6-rc/pipewire/run
new file mode 100644
index 0000000..c0b55a1
--- /dev/null
+++ b/img/app/etc/s6-rc/pipewire/run
@@ -0,0 +1,20 @@
+#!/bin/execlineb -P
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2023-2024 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
+
+s6-ipcserver-socketbinder -B /run/user/0/pipewire-0
+fdmove -c 3 0
+
+s6-ipcserver-socketbinder -B /run/user/0/pipewire-0-manager
+fdmove -c 4 0
+
+redirfd -r 0 /dev/null
+
+# Notify readiness.
+if { fdmove 1 5 echo }
+fdclose 5
+
+export LISTEN_FDS 2
+getpid LISTEN_PID
+pipewire
diff --git a/img/app/etc/s6-rc/pipewire/type b/img/app/etc/s6-rc/pipewire/type
new file mode 100644
index 0000000..5883cff
--- /dev/null
+++ b/img/app/etc/s6-rc/pipewire/type
@@ -0,0 +1 @@
+longrun
diff --git a/img/app/etc/s6-rc/wayland-proxy-virtwl/dependencies.d/directories b/img/app/etc/s6-rc/wayland-proxy-virtwl/dependencies.d/directories
new file mode 100644
index 0000000..e69de29
diff --git a/img/app/etc/s6-rc/wayland-proxy-virtwl/run b/img/app/etc/s6-rc/wayland-proxy-virtwl/run
index 7b80343..c1e0e08 100755
--- a/img/app/etc/s6-rc/wayland-proxy-virtwl/run
+++ b/img/app/etc/s6-rc/wayland-proxy-virtwl/run
@@ -1,17 +1,6 @@
#!/bin/execlineb -P
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2023-2024 Alyssa Ross <hi@alyssa.is>
-#
-# Directory creation (if it's copyrightable):
-# SPDX-License-Identifier: MIT
-# SPDX-FileCopyrightText: 2022 Unikie
-
-foreground { mkdir /tmp/.X11-unix }
-foreground { mkdir /run/user }
-foreground {
- umask 077
- mkdir /run/user/0
-}

s6-ipcserver-socketbinder -B /run/user/0/wayland-0
fdmove -c 3 0
diff --git a/img/app/etc/s6-rc/wireplumber/dependencies.d/dbus b/img/app/etc/s6-rc/wireplumber/dependencies.d/dbus
new file mode 100644
index 0000000..e69de29
diff --git a/img/app/etc/s6-rc/wireplumber/dependencies.d/pipewire b/img/app/etc/s6-rc/wireplumber/dependencies.d/pipewire
new file mode 100644
index 0000000..e69de29
diff --git a/img/app/etc/s6-rc/wireplumber/run b/img/app/etc/s6-rc/wireplumber/run
new file mode 100644
index 0000000..6d6a549
--- /dev/null
+++ b/img/app/etc/s6-rc/wireplumber/run
@@ -0,0 +1,16 @@
+#!/bin/execlineb -P
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2023-2024 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
+#
+# Directory creation (if it's copyrightable):
+# SPDX-License-Identifier: MIT
+# SPDX-FileCopyrightText: 2022 Unikie
+
+foreground { mkdir /tmp/.X11-unix }
+foreground { mkdir /run/user }
+foreground {
+ umask 077
+ mkdir /run/user/0
+}
+
diff --git a/img/app/etc/s6-rc/wireplumber/type b/img/app/etc/s6-rc/wireplumber/type
new file mode 100644
index 0000000..5883cff
--- /dev/null
+++ b/img/app/etc/s6-rc/wireplumber/type
@@ -0,0 +1 @@
+longrun
--
Sincerely,
Demi Marie Obenour (she/her/hers)

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 7253 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]