From 3fb3ab214ea36e1adda214b84d39dd1c919175e5 Mon Sep 17 00:00:00 2001 From: Jeremy Cline Date: Fri, 31 Jan 2025 10:13:55 -0500 Subject: [PATCH] Add tmpfiles configuration for x11, Wayland, and PulseAudio support This includes the tmpfiles config to link the various WSL-provided service sockets to the expected location. It also includes an override snippet for systemd-firstboot to have it not run inside WSL for the present as it hangs forever. --- firstboot-override.conf | 2 ++ wsl-setup-tmpfiles.conf | 1 + wsl-setup-user-tmpfiles.conf | 3 +++ wsl-setup.spec | 23 +++++++++++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 firstboot-override.conf create mode 100644 wsl-setup-tmpfiles.conf create mode 100644 wsl-setup-user-tmpfiles.conf diff --git a/firstboot-override.conf b/firstboot-override.conf new file mode 100644 index 0000000..c6fab5d --- /dev/null +++ b/firstboot-override.conf @@ -0,0 +1,2 @@ +[Unit] +ConditionVirtualization=!wsl diff --git a/wsl-setup-tmpfiles.conf b/wsl-setup-tmpfiles.conf new file mode 100644 index 0000000..23ba7b5 --- /dev/null +++ b/wsl-setup-tmpfiles.conf @@ -0,0 +1 @@ +L+ /tmp/.X11-unix - - - - /mnt/wslg/.X11-unix diff --git a/wsl-setup-user-tmpfiles.conf b/wsl-setup-user-tmpfiles.conf new file mode 100644 index 0000000..6a155a8 --- /dev/null +++ b/wsl-setup-user-tmpfiles.conf @@ -0,0 +1,3 @@ +L+ /run/user/%U/wayland-0.lock - - - - /mnt/wslg/runtime-dir/wayland-0.lock +L+ /run/user/%U/wayland-0 - - - - /mnt/wslg/runtime-dir/wayland-0 +L+ /run/user/%U/pulse - - - - /mnt/wslg/runtime-dir/pulse diff --git a/wsl-setup.spec b/wsl-setup.spec index a8308cb..f8ceaac 100644 --- a/wsl-setup.spec +++ b/wsl-setup.spec @@ -17,6 +17,11 @@ Source1: LICENSE Source2: wsl.conf Source3: wsl-distribution.conf Source4: wsl-oobe.sh +Source5: firstboot-override.conf +Source6: wsl-setup-tmpfiles.conf +Source7: wsl-setup-user-tmpfiles.conf + +BuildRequires: systemd-rpm-macros %description @@ -41,6 +46,21 @@ install -Dpm0644 -t %{buildroot}%{_prefix}/lib/ %{SOURCE3} install -Dpm0755 -T %{SOURCE4} %{buildroot}%{_libexecdir}/wsl/oobe.sh ln -s ..%{_prefix}/lib/wsl-distribution.conf %{buildroot}%{_sysconfdir}/wsl-distribution.conf +# WSL provides a socket for x11, but we need to ensure its linked to in /tmp. +# The official recommendation is to disable tmpfiles entirely, but it would be +# nice to work with it, instead. +# https://learn.microsoft.com/en-us/windows/wsl/build-custom-distro#systemd-recommendations +install -Dpm0644 %{SOURCE6} %{buildroot}%{_tmpfilesdir}/%{name}.conf + +# WSL provides a Wayland and PulseAudio docket as well, which are expected to be in +# the user's runtime directory. This configuration sets up the links for each user. +install -Dpm0644 %{SOURCE7} %{buildroot}%{_user_tmpfilesdir}/%{name}.conf + +# Currently systemd-firstboot hangs forever attempting to acquire the console; this is +# problematic since many other services wait for it to complete before starting, including +# things like the system D-Bus. Configure it to not run in WSL (a preset didn't seem to work) +# until we can see about adjusting either WSL or systemd to make it behave. +install -Dpm0644 %{SOURCE5} %{buildroot}%{_unitdir}/systemd-firstboot.service.d/override.conf %check grep "defaultName = %{default_name}" %{buildroot}%{_sysconfdir}/wsl-distribution.conf @@ -51,6 +71,9 @@ grep "defaultName = %{default_name}" %{buildroot}%{_sysconfdir}/wsl-distribution %{_prefix}/lib/wsl-distribution.conf %{_sysconfdir}/wsl-distribution.conf %{_libexecdir}/wsl/oobe.sh +%{_tmpfilesdir}/%{name}.conf +%{_user_tmpfilesdir}/%{name}.conf +%{_unitdir}/systemd-firstboot.service.d/override.conf %license LICENSE