patches and low-level development discussion
 help / color / mirror / code / Atom feed
* [RFC PATCH] Run PipeWire and WirePlumber in the VMs
@ 2025-06-17 15:30 Demi Marie Obenour
  2025-06-26  8:35 ` Alyssa Ross
  0 siblings, 1 reply; 2+ messages in thread
From: Demi Marie Obenour @ 2025-06-17 15:30 UTC (permalink / raw)
  To: Alyssa Ross; +Cc: Spectrum OS Development


[-- 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 --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH] Run PipeWire and WirePlumber in the VMs
  2025-06-17 15:30 [RFC PATCH] Run PipeWire and WirePlumber in the VMs Demi Marie Obenour
@ 2025-06-26  8:35 ` Alyssa Ross
  0 siblings, 0 replies; 2+ messages in thread
From: Alyssa Ross @ 2025-06-26  8:35 UTC (permalink / raw)
  To: Demi Marie Obenour; +Cc: Spectrum OS Development

[-- Attachment #1: Type: text/plain, Size: 4613 bytes --]

Demi Marie Obenour <demiobenour@gmail.com> writes:

> 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>

We indeed can't test sound works, but doat least try running the VM and
make sure that it works like it did before!  With this applied, the
application no longer starts, because the new files weren't added to the
Makefile.

Well done for figuring out s6 though. :)

> ---
>  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

Files that can't include comments need to have .license files next to
them for "reuse lint" to pass.  (This is one of the checks included if
you do a full release build by building release.nix.)

> 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

Want to send the permissions changes from this patch separately?  We
probably need to check the permissions for all mountpoints across hosts
and guests.

> +tmpfs		/run		tmpfs	defaults			0	0

We already have /run from s6-linux-init.

> 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

This needs to be executable.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-26  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 15:30 [RFC PATCH] Run PipeWire and WirePlumber in the VMs Demi Marie Obenour
2025-06-26  8:35 ` Alyssa Ross

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).