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.
This commit is contained in:
Jeremy Cline 2025-01-31 10:13:55 -05:00
parent 36a22f247c
commit 3fb3ab214e
No known key found for this signature in database
4 changed files with 29 additions and 0 deletions

2
firstboot-override.conf Normal file
View File

@ -0,0 +1,2 @@
[Unit]
ConditionVirtualization=!wsl

1
wsl-setup-tmpfiles.conf Normal file
View File

@ -0,0 +1 @@
L+ /tmp/.X11-unix - - - - /mnt/wslg/.X11-unix

View File

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

View File

@ -17,6 +17,11 @@ Source1: LICENSE
Source2: wsl.conf Source2: wsl.conf
Source3: wsl-distribution.conf Source3: wsl-distribution.conf
Source4: wsl-oobe.sh Source4: wsl-oobe.sh
Source5: firstboot-override.conf
Source6: wsl-setup-tmpfiles.conf
Source7: wsl-setup-user-tmpfiles.conf
BuildRequires: systemd-rpm-macros
%description %description
@ -41,6 +46,21 @@ install -Dpm0644 -t %{buildroot}%{_prefix}/lib/ %{SOURCE3}
install -Dpm0755 -T %{SOURCE4} %{buildroot}%{_libexecdir}/wsl/oobe.sh install -Dpm0755 -T %{SOURCE4} %{buildroot}%{_libexecdir}/wsl/oobe.sh
ln -s ..%{_prefix}/lib/wsl-distribution.conf %{buildroot}%{_sysconfdir}/wsl-distribution.conf 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 %check
grep "defaultName = %{default_name}" %{buildroot}%{_sysconfdir}/wsl-distribution.conf 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 %{_prefix}/lib/wsl-distribution.conf
%{_sysconfdir}/wsl-distribution.conf %{_sysconfdir}/wsl-distribution.conf
%{_libexecdir}/wsl/oobe.sh %{_libexecdir}/wsl/oobe.sh
%{_tmpfilesdir}/%{name}.conf
%{_user_tmpfilesdir}/%{name}.conf
%{_unitdir}/systemd-firstboot.service.d/override.conf
%license LICENSE %license LICENSE