Open twhitehead opened 2 days ago
I cannot reproduce this problem, could you share how you configure sway
on this host using NixOS module options?
For sure. Thank for checking this out!
$ cat ~/.config/sway/config
# Default config for sway
#
# Copy this to ~/.config/sway/config and edit it to your liking.
#
# Read `man 5 sway` for a complete reference.
include /etc/sway/config.d/*
...
and
$ cat /etc/sway/config.d/*
# Import the most important environment variables into the D-Bus and systemd
# user environments (e.g. required for screen sharing and Pinentry prompts):
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
The indicator that there is a problem is if
$ busctl --user introspect org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
...
org.freedesktop.portal.Realtime interface - - -
.MakeThreadHighPriorityWithPID method tti - -
.MakeThreadRealtimeWithPID method ttu - -
.MaxRealtimePriority property i 20 emits-change
.MinNiceLevel property i -15 emits-change
.RTTimeUSecMax property x 200000 emits-change
.version property u 1 emits-change
org.freedesktop.portal.Trash interface - - -
.TrashFile method h u -
.version property u 1 emits-change
doesn't list org.freedesktop.portal.ScreenCast
.
You can manually set the environment variable into you systemd user environment and restart the service to see the difference
$ systemctl --user import-environment NIX_XDG_DESKTOP_PORTAL_DIR
$ systemctl --user stop xdg-desktop-portal
$ busctl --user introspect org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
...
org.freedesktop.portal.Realtime interface - - -
.MakeThreadHighPriorityWithPID method tti - -
.MakeThreadRealtimeWithPID method ttu - -
.MaxRealtimePriority property i 20 emits-change
.MinNiceLevel property i -15 emits-change
.RTTimeUSecMax property x 200000 emits-change
.version property u 1 emits-change
org.freedesktop.portal.ScreenCast interface - - -
.CreateSession method a{sv} o -
.OpenPipeWireRemote method oa{sv} h -
.SelectSources method oa{sv} o -
.Start method osa{sv} o -
.AvailableCursorModes property u 3 emits-change
.AvailableSourceTypes property u 1 emits-change
.version property u 5 emits-change
org.freedesktop.portal.Trash interface - - -
.TrashFile method h u -
.version property u 1 emits-change
The key difference that you see when you set it to run xdg-desktop-portal
with the -v
option is that with out NIX_XDG_PORTAL_DIR
set it says
XDP: load portals from /nix/store/yhf8h0pqdabwpl4gjg66bnj7j7bprylq-xdg-desktop-portal-1.18.4/share/xdg-desktop-portal/portals
vs with it set
XDP: load portals from /run/current-system/sw/share/xdg-desktop-portal/portals
Inspecting these two directories I see
$ ls -l /nix/store/yhf8h0pqdabwpl4gjg66bnj7j7bprylq-xdg-desktop-portal-1.18.4/share/xdg-desktop-portal/portals
ls: cannot access '/nix/store/yhf8h0pqdabwpl4gjg66bnj7j7bprylq-xdg-desktop-portal-1.18.4/share/xdg-desktop-portal/portals': No such file or directory
vs
$ ls -l /run/current-system/sw/share/xdg-desktop-portal/portals/
total 8
lrwxrwxrwx 2 root root 118 Dec 31 1969 kde.portal -> /nix/store/9bv8adrhk0qm55jrm2hh0qqd3xka6v2q-xdg-desktop-portal-kde-5.27.11/share/xdg-desktop-portal/portals/kde.portal
lrwxrwxrwx 2 root root 116 Dec 31 1969 wlr.portal -> /nix/store/5ylrgc8iy6lqn35nkglpnfl6pzxrdwir-xdg-desktop-portal-wlr-0.7.1/share/xdg-desktop-portal/portals/wlr.portal
$ cat /run/current-system/sw/share/xdg-desktop-portal/portals/wlr.portal
[portal]
DBusName=org.freedesktop.impl.portal.desktop.wlr
Interfaces=org.freedesktop.impl.portal.Screenshot;org.freedesktop.impl.portal.ScreenCast;
UseIn=wlroots;sway;Wayfire;river;phosh;Hyprland;
The fact that ScreenCast
(and Screenshot
) are supposed to come from the wrl
portal is in the sway-portals.conf
$ cat /etc/xdg/xdg-desktop-portal/sway-portals.conf
[preferred]
default=gtk
org.freedesktop.impl.portal.Inhibit=none
org.freedesktop.impl.portal.ScreenCast=wlr
org.freedesktop.impl.portal.Screenshot=wlr
and xdg-desktop-portal
loads this as XDG_CURRENT_DESKTOP=sway
is exported by /etc/sway/config.d/nixos.conf
.
Thank you for these details. How do you configure sway
in your NixOS host config? It looks to me like something's missing, because the xdg
NixOS module should already set NIX_XDG_DESKTOP_PORTAL_DIR
in your environment (it does for me, I see the variable).
Do you use programs.sway.enable = true;
?
I do use programs.sway.enable = true
. And it does set it in my environment
$ echo $NIX_XDG_DESKTOP_PORTAL_DIR
/run/current-system/sw/share/xdg-desktop-portal/portals
It is just that this isn't being copied to the user systemd environment (so services started by systemd don't see it)
$ systemctl --user show-environment
CUPS_DATADIR=/nix/store/djhvfw1wf14mar9my3dmb491g8zmdkzc-cups-progs/share/cups
GDK_PIXBUF_MODULE_FILE=/nix/store/iq8i90xi6qwyq60n28fwpd1lqlpqsks0-gdk-pixbuf-loaders.cache
GIO_EXTRA_MODULES=/nix/store/wv07mkwb06kbms7y20kcg174scg9gacl-dconf-0.40.0-lib/lib/gio/modules
GTK_A11Y=none
GTK_PATH=/home/tyson/.nix-profile/lib/gtk-2.0:/home/tyson/.nix-profile/lib/gtk-3.0:/home/tyson/.nix-profile/lib/gtk-4.0:/nix/profile/lib/gtk-2.0:/nix/profile/lib/gtk-3.0:/nix/profile/lib/gtk-4.0:/home/tyson/.local/state/nix/profile/lib/gtk-2.0:/home/tyson/.local/state/nix>
HOME=/home/tyson
INFOPATH=/home/tyson/.nix-profile/info:/home/tyson/.nix-profile/share/info:/nix/profile/info:/nix/profile/share/info:/home/tyson/.local/state/nix/profile/info:/home/tyson/.local/state/nix/profile/share/info:/etc/profiles/per-user/tyson/info:/etc/profiles/per-user/tyson/sh>
KPACKAGE_DEP_RESOLVERS_PATH=/nix/store/2khzq9a39n1c7604pgd9d3yazqn91mf2-frameworkintegration-5.116.0/libexec/kf5/kpackagehandlers
LANG=en_US.UTF-8
LIBEXEC_PATH=/home/tyson/.nix-profile/libexec:/nix/profile/libexec:/home/tyson/.local/state/nix/profile/libexec:/etc/profiles/per-user/tyson/libexec:/nix/var/nix/profiles/default/libexec:/run/current-system/sw/libexec
LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
LOGNAME=tyson
NIX_PATH=nixpkgs=flake:nixpkgs:/nix/var/nix/profiles/per-user/root/channels
NO_AT_BRIDGE=1
PATH=/nix/store/h05qs7dk5i6490ji0f9fndia9q2wwjac-systemd-255.9/bin/
QML2_IMPORT_PATH=/home/tyson/.nix-profile/lib/qt-5.15.14/qml:/home/tyson/.nix-profile/lib/qt-6/qml:/nix/profile/lib/qt-5.15.14/qml:/nix/profile/lib/qt-6/qml:/home/tyson/.local/state/nix/profile/lib/qt-5.15.14/qml:/home/tyson/.local/state/nix/profile/lib/qt-6/qml:/etc/prof>
QTWEBKIT_PLUGIN_PATH=/home/tyson/.nix-profile/lib/mozilla/plugins/:/nix/profile/lib/mozilla/plugins/:/home/tyson/.local/state/nix/profile/lib/mozilla/plugins/:/etc/profiles/per-user/tyson/lib/mozilla/plugins/:/nix/var/nix/profiles/default/lib/mozilla/plugins/:/run/current>
QT_PLUGIN_PATH=/home/tyson/.nix-profile/lib/qt-5.15.14/plugins:/home/tyson/.nix-profile/lib/qt-6/plugins:/nix/profile/lib/qt-5.15.14/plugins:/nix/profile/lib/qt-6/plugins:/home/tyson/.local/state/nix/profile/lib/qt-5.15.14/plugins:/home/tyson/.local/state/nix/profile/lib/>
SHELL=/run/current-system/sw/bin/fish
TERMINFO_DIRS=/home/tyson/.nix-profile/share/terminfo:/nix/profile/share/terminfo:/home/tyson/.local/state/nix/profile/share/terminfo:/etc/profiles/per-user/tyson/share/terminfo:/nix/var/nix/profiles/default/share/terminfo:/run/current-system/sw/share/terminfo
TZDIR=/etc/zoneinfo
USER=tyson
XCURSOR_PATH=/home/tyson/.icons:/home/tyson/.local/share/icons:/home/tyson/.nix-profile/share/icons:/home/tyson/.nix-profile/share/pixmaps:/nix/profile/share/icons:/nix/profile/share/pixmaps:/home/tyson/.local/state/nix/profile/share/icons:/home/tyson/.local/state/nix/pro>
XDG_CONFIG_DIRS=/etc/xdg:/home/tyson/.nix-profile/etc/xdg:/nix/profile/etc/xdg:/home/tyson/.local/state/nix/profile/etc/xdg:/etc/profiles/per-user/tyson/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg
XDG_DATA_DIRS=/nix/store/w6f03ndcjaqirvzyh2bx2689bw7mbcyi-desktops/share:/home/tyson/.nix-profile/share:/nix/profile/share:/home/tyson/.local/state/nix/profile/share:/etc/profiles/per-user/tyson/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share
XDG_RUNTIME_DIR=/run/user/1000
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DISPLAY=:1
SWAYSOCK=/run/user/1000/sway-ipc.1000.24227.sock
WAYLAND_DISPLAY=wayland-1
XDG_CURRENT_DESKTOP=sway
How do you start sway
when booting the system? Do you use a custom systemd service to start it?
I have no custom systemd services. I have
programs.sway.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
services.displayManager.sddm.enable = true;
when I boot I get an sddm login screen. At the bottom I can pick between sway (wayland) and kde (x11) and kde (wayland). I pick sway (wayland) and login to get sway.
I gather you are saying that when you run
$ systemctl --user show-environment
you see
NIX_XDG_DESKTOP_PORTAL_DIR=/run/current-system/sw/share/xdg-desktop-portal/portals
in the list somehow?
The NIX_XDG_DESKTOP_PORTAL_DIR
thing was introduced back in Februray by @jtojnar in 3b2f55e89f8233333b191bb7b4c9d6448a4a2d74.
Not sure how things worked (or not) before then.
Describe the bug
Can't share screen under sway as xdg-desktop-portal in 24.05 as it is not hooking up to the wlr backend correctly. Running
chromium --enable-logging --v=2
and then trying to stare the screen in google meet, for example logsOverriding the systemd user
xdg-desktop-portal.service
to start it with the-v
option (make a copy under ~/.config/systemd/user, add the verbose flag, and restart it) reveals that it is not loading the portals from the /run/current-system/sw/share/xdg-desktop-portal/portals directorybecause
NIX_XDG_DESKTOP_PORTAL_DIR
is not being exported to the systemd in /etc/sway/config.d/nixos.conf@laalsaas @primeos as people who show up on the relevant module line.
I'll do a pull request shortly too. Would be great if this could make it into 24.11 and maybe be backported to 24.05 too.