Open jsravn opened 4 years ago
Is not this the same as https://github.com/NixOS/nixpkgs/issues/89528#issuecomment-640086776? That should have been fixed https://github.com/NixOS/nixpkgs/pull/90039.
But if pkgs.unstable
refers to 9480bae3370, that should already have 0.3.6: https://github.com/NixOS/nixpkgs/blob/9480bae3370/pkgs/development/libraries/pipewire/default.nix
I get the crash w/ 0.3.6 as well. I think 0.3.6 fixed an issue w/ 0.2 client protocol. However I can't even get to that point as xdg-desktop-portal itself is crashing.
Could you try https://github.com/NixOS/nixpkgs/pull/88598?
cc @flokli
@jtojnar It seems to be working w/ 1.7.2! Awesome, thanks!
On 20.03 (unstable is the nixos unstable channel):
{ stdenv
, fetchFromGitHub
, nixosTests
, substituteAll
, autoreconfHook
, pkgconfig
, libxml2
, glib
, unstable
, fontconfig
, flatpak
, gsettings-desktop-schemas
, acl
, dbus
, fuse
, libportal
, geoclue2
, json-glib
, wrapGAppsHook
}:
stdenv.mkDerivation rec {
pname = "xdg-desktop-portal";
version = "1.7.2";
outputs = [ "out" "installedTests" ];
src = fetchFromGitHub {
owner = "flatpak";
repo = pname;
rev = version;
sha256 = "0rkwpsmbn3d3spkzc2zsd50l2r8pp4la390zcpsawaav8w7ql7xm";
};
patches = [
# Hardcode paths used by x-d-p itself.
(substituteAll {
src = ./fix-paths.patch;
inherit flatpak;
})
];
nativeBuildInputs = [
autoreconfHook
pkgconfig
libxml2
wrapGAppsHook
];
buildInputs = [
glib
unstable.pipewire
fontconfig
flatpak
acl
dbus
geoclue2
fuse
libportal
gsettings-desktop-schemas
json-glib
];
configureFlags = [
"--enable-installed-tests"
];
makeFlags = [
"installed_testdir=${placeholder "installedTests"}/libexec/installed-tests/xdg-desktop-portal"
"installed_test_metadir=${placeholder "installedTests"}/share/installed-tests/xdg-desktop-portal"
];
passthru = {
tests = {
installedTests = nixosTests.installed-tests.xdg-desktop-portal;
};
};
meta = with stdenv.lib; {
description = "Desktop integration portals for sandboxed apps";
license = licenses.lgpl21;
maintainers = with maintainers; [ jtojnar ];
platforms = platforms.linux;
};
}
@jsravn with https://github.com/NixOS/nixpkgs/pull/88598 merged, I here are my findings:
I used this VM test description:
import ./make-test-python.nix ({ pkgs, ... }: {
name = "chrome-wayland-screensharing";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ flokli ];
};
machine =
{ pkgs, ... }: {
imports = [ ./common/user-account.nix ];
nixpkgs.config.allowUnfree = true;
virtualisation.memorySize = 1024;
programs.sway.enable = true;
services.xserver.enable = true; #??
services.xserver.displayManager.sddm = {
enable = true;
autoLogin = {
enable = true;
user = "alice";
};
};
services.xserver.displayManager.defaultSession = "sway";
hardware.pulseaudio.enable = true;
sound.enable = true;
xdg.portal = {
enable = true;
extraPortals = with pkgs; [ xdg-desktop-portal-wlr ];
gtkUsePortal = true;
};
services.pipewire.enable = true;
environment.systemPackages = [
pkgs.google-chrome-beta
pkgs.chromium
];
};
testScript = { nodes, ... }: let
user = nodes.machine.config.users.users.alice;
in ''
machine.start()
with subtest("Wait for sway to boot up"):
machine.wait_for_file("/run/user/${toString user.uid}/wayland-0.lock")
machine.sleep(10)
# alt+return, run `systemctl --user import-environment`
# Run chrome
# Go to chrome://flags and enable the pipewire RTC support (only available in unstable currently).
# Go to https://mozilla.github.io/webrtc-landing/gum_test.html and try to screenshare.
# for a real NixOS tests, this needs to be tested without having to rely on networking
'';
})
I manually built the test driver usingnix-build nixos/tests/chrome-wayland.nix -A driver
, ran the VM via result/bin/nixos-run-vms
and then followed the comments in the script. This obviously still needs some work for a proper test.
My findings:
systemctl --user import-environment
, as shown in the example in https://nixos.wiki/wiki/Sway.Error messages otherwise:
machine # [ 148.124107] pipewire[3540]: [E][000000148.056183][dbus.c:319 impl_get_connection()] Failed to connect to system bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
machine # [ 148.126469] pipewire[3540]: [E][000000148.058780][module-portal.c:782 pipewire__module_init()] Failed to connect to system bus
machine # [ 148.128040] pipewire[3540]: [E][000000148.058790][impl-module.c:281 pw_context_load_module()] "/nix/store/q29k6dmcr54sr3s6qbvai42hcrrawpvh-pipewire-0.3.6-lib/lib/pipewire-0.3/libpipewire-module-portal.so": failed to initialize: Cannot allocate memory
machine # [ 148.133684] pipewire[3540]: [E][000000148.058853][daemon-config.c:202 pw_daemon_config_run_commands()] could not run command load-module: could not load module "libpipewire-module-portal": Cannot allocate memory
machine # [ 148.138694] pipewire[3540]: [E][000000148.058860][main.c:123 main()] failed to run config commands: Cannot allocate memory
This is especially annoying, as pipewire
is socket-activated, and needs to be restarted if it has already been before the import-environment
was run. We should really do this in a sway
NixOS module in a sane way.
Using google-chrome-beta
as a client, the daemon doesn't segfault anymore, but it still complains about the protocol:
machine # [ 209.423267] pipewire[3798]: [W][000000209.355581][module-rtkit.c:499 idle_func()] could not make thread realtime: No such file or directory
machine # [ 209.446129] pipewire[3800]: [E][000000209.378505][bluez5-dbus.c:2022 get_managed_objects_reply()] GetManagedObjects() failed: org.freedesktop.DBus.Error.ServiceUnknown
machine # [ 226.724437] pipewire[3798]: [W][000000226.656777][impl-client.c:608 pw_impl_client_update_permissions()] client 0x2161890: invalid global 469835776
machine # [ 226.735033] pipewire[3798]: [W][000000226.667615][impl-client.c:608 pw_impl_client_update_permissions()] client 0x2175410: invalid global 469834768
machine # [ 260.104445] pipewire[3798]: [W][000000260.036721][impl-client.c:608 pw_impl_client_update_permissions()] client 0x2189190: invalid global 469842528
Using chromium
, the daemon doesn't complain about the protocol. I can share the screen, but it's mostly black (I mostly seem to be sharing a mouse cursor moving around a black screen)
We might also need to explicitly enable audio when the pipewire daemon - I saw some complaints in the log, and enabled both pulseaudio and hardware.sound
, but I assume hardware.sound
only should be sufficient.
I have this in my sway config:
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK DBUS_SESSION_BUS_ADDRESS
exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK DBUS_SESSION_BUS_ADDRESS
I don't think there is a way around this - as DISPLAY won't exist until sway starts. Arguably sway itself should be exporting this but it is agnostic of systemd/dbus.
Also - any tips to run the test? I'm trying to run it within sway - I have kvm-intel enabled and libvirtd. The VM boots up but I can only access the ttys - the graphical tty7 just shows a black screen. No errors in the logs. I'm guessing I need some qemu setting...
@jsravn I think the pipewire systemd user service is missing DBUS_SESSION_BUS_ADDRESS
here - not sure about why it's not part of the environment of systemd user services… :thinking:
Regarding DISPLAY
, WAYLAND_DISPLAY
, SWAYSOCK
etc.: https://github.com/swaywm/sway/wiki/Systemd-integration provides some suggestions on how this can be done in a less racy way, which should probably put into the Sway module (and abandon the other hacks currently in our Wiki)
I'm curious. i got it to work with google-chrome easily quite a while ago. i documented that here: https://github.com/colemickens/nixpkgs-wayland/pull/211
Thanks! I forgot that you need to set XDG_CURRENT_DESKTOP=sway
and XDG_SESSION_TYPE=wayland
for xdg-desktop-portal-wlr to activate.
Using the tips of @betaboon I got this working as well under GNOME 3.36.3. The only thing needed was to wrap the google-chrome with the older pipewire_0_2
. That was by head-ache that I was trying with the latest version of pipewire first.
I revised the derivation a bit: google-chrome-with-pipewire/default.nix
{ makeWrapper, stdenv, google-chrome, pipewire }:
with builtins;
let
binName = head (filter (n: match "^\\..*" n == null)
(attrNames (readDir "${google-chrome}/bin")));
pnameFromName = p: replaceStrings [ "-${p.version}" ] [ "" ] p.name;
in stdenv.mkDerivation {
pname = "${pnameFromName google-chrome}-with-pipewire";
inherit (google-chrome) version;
buildInputs = [ makeWrapper ];
buildCommand = ''
makeWrapper \
"${google-chrome}/bin/${binName}" \
$out/bin/${binName} \
--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ pipewire ]} \
--add-flags '--enable-features=WebRTCPipeWireCapturer'
'';
}
and then use it like this in an overlay:
final: prev:
{
google-chrome-beta-with-pipewire =
prev.callPackage ./google-chrome-with-pipewire {
google-chrome = final.google-chrome-beta;
pipewire = final.pipewire_0_2;
};
google-chrome-dev-with-pipewire =
prev.callPackage ./google-chrome-with-pipewire {
google-chrome = final.google-chrome-dev;
pipewire = final.pipewire_0_2;
};
}
One interesting thing is that this works with full screen sharing, while it does not seem to work with sharing individual windows, however that works without pipewire, so might have to run with two different instances of chrome to achieve that.
@terlar i believe xdg-desktop-portal-wlr
only supports sharing the full screen and not individual windows atm. i believe sharing individual windows works only for xwayland windows (which you could identify by using xeyes
)
It's probably fine to add pipewire_0_2
to google-chrome's library path, like we do for chromium.
I marked this as stale due to inactivity. → More info
I guess this can be closed now. With #104504 it worked for me, but I'm not sure if it still works.
The situation will hopefully improve in 2021 with support for PipeWire 0.3:
@primeos if it works for you know, a working config would be nice. I can't really get it to work.
Running unstable, chromium just tells me:
[30080:30080:0112/173510.029650:ERROR:base_capturer_pipewire.cc(517)] Failed to create a screen cast session: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.portal.Desktop was not provided by any .service files
[30080:30080:0112/173510.030252:ERROR:base_capturer_pipewire.cc(517)] Failed to create a screen cast session: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.portal.Desktop was not provided by any .service files
Chromium wrapper:
#!/bin/sh
dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK DBUS_SESSION_BUS_ADDRESS
systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK DBUS_SESSION_BUS_ADDRESS
chromium --enable-features=UseOzonePlatform --ozone-platform=wayland
according configuration.nix:
xdg.portal = {
enable = true;
extraPortals = [ pkgs.xdg-desktop-portal-wlr ];
gtkUsePortal = true;
};
services.pipewire = {
enable = true;
};
programs.sway = {
enable = true;
wrapperFeatures = {
base = true;
gtk = true;
};
extraSessionCommands =
''
export SDL_VIDEODRIVER=wayland
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
export _JAVA_AWT_WM_NONREPARENTING=1
export SUDO_ASKPASS="${pkgs.ksshaskpass}/bin/ksshaskpass"
export SSH_ASKPASS="${pkgs.ksshaskpass}/bin/ksshaskpass"
export XDG_SESSION_TYPE=wayland
export XDG_CURRENT_DESKTOP=sway
'';
@d4g your config LGTM but you might need xdg-desktop-portal-gtk
in xdg.portal.extraPortals
. In any case it looks like the assertion in nixos/modules/config/xdg/portal.nix
isn't ideal:
assertions = [
{ assertion = (cfg.gtkUsePortal -> cfg.extraPortals != []);
message = "Setting xdg.portal.gtkUsePortal to true requires a portal implementation in xdg.portal.extraPortals such as xdg-desktop-portal-gtk or xdg-desktop-portal-kde.";
}
];
Back when I tested this it was just our of curiosity / for fun so my config might not be very useful / ideal but here is the relevant stuff that is still in my /etc/nixos/configuration.nix
(I hope that I didn't remove anything after testing):
Unfortunately I don't remember how I launched Chromium, but IIRC I only ran systemctl --user import-environment
(since it was only for testing purposes) before.
I also gave it another quick try but it might be broken again. I get a slightly different error though:
[16941:16941:0112/210416.016999:ERROR:base_capturer_pipewire.cc(517)] Failed to create a screen cast session: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.ScreenCast” on object at path /org/freedesktop/portal/desktop
[16941:16941:0112/210416.017176:ERROR:base_capturer_pipewire.cc(517)] Failed to create a screen cast session: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.ScreenCast” on object at path /org/freedesktop/portal/desktop
[16976:17017:0112/210416.230554:ERROR:ssl_client_socket_impl.cc(960)] handshake failed; returned -1, SSL error code 1, net_error -218
[16976:17017:0112/210416.230658:ERROR:ssl_client_socket_impl.cc(960)] handshake failed; returned -1, SSL error code 1, net_error -218
[16941:16941:0112/210418.560731:ERROR:base_capturer_pipewire.cc(517)] Failed to create a screen cast session: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.ScreenCast” on object at path /org/freedesktop/portal/desktop
[17023:13:0112/210418.591310:ERROR:client_native_pixmap_dmabuf.cc(252)] Failed to mmap dmabuf: Function not implemented (38)
In any case the GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown
might be easy to resolve in case anyone is interested. Could be due to an upstream change in the xdg-desktop-portal
package (that provides e.g. share/dbus-1/interfaces/org.freedesktop.portal.ScreenCast.xml
) or due to a change in the Nixpkgs package/module.
Thanks @primeos . I check if this works if I add xdg-desktop-portal-gtk. If it doesn't, we should probably reopen the issue as it is not resolved?
Should this change work immediately? Would I need to restart my user session? Should there be anything visibly running as process from the whole desktop portal software packages?
So I applied the changes, logged in again, still no success:
[11577:11577:0113/085406.053075:ERROR:base_capturer_pipewire.cc(517)] Failed to create a screen cast session: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.portal.Desktop was not provided by any .service files
[11577:11577:0113/085406.053168:ERROR:base_capturer_pipewire.cc(517)] Failed to create a screen cast session: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.portal.Desktop was not provided by any .service files
[11643:11643:0113/085409.411188:ERROR:gl_surface_presentation_helper.cc(259)] GetVSyncParametersIfAvailable() failed for 2 times!
I think we should really only close this issue, after we have a working configuration that is probably documented, or even have a configuration option that will set the appropriate settings where feasible.
I also did a clean reboot.
Error messages on Chromium start:
top.DBus.Properties.Get: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[3481:3740:0113/091142.591750:ERROR:object_proxy.cc(621)] Failed to call method: org.freedesktop.UPower.GetDisplayDevice: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[3481:3740:0113/091142.593086:ERROR:object_proxy.cc(621)] Failed to call method: org.freedesktop.UPower.EnumerateDevices: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
[3576:3576:0113/091147.811782:ERROR:gl_surface_presentation_helper.cc(259)] GetVSyncParametersIfAvailable() failed for 1 times!
[3481:3481:0113/091154.318135:ERROR:base_capturer_pipewire.cc(517)] Failed to create a screen cast session: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.ScreenCast” on object at path /org/freedesktop/portal/desktop
[3481:3481:0113/091154.318170:ERROR:base_capturer_pipewire.cc(517)] Failed to create a screen cast session: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.ScreenCast” on object at path /org/freedesktop/portal/desktop
Also it seems that a restart of the systemd user session is required for the settings to work. Now it seems to me, that the font rendering is completely broken. Probably related to the xdg-desktop-portal:
This is in termite.
waybar
The font rendering in sway itself is still fine. Firefox an chromium look alright, also the titles of the windows are ok.
i ran into the issue of gtkUsePortal = true;
breaking gtk3-antialiasing a while ago myself.
i ran into the issue of
gtkUsePortal = true;
breaking gtk3-antialiasing a while ago myself.
Did you raise an according issue already?
i dont remember, but dont think so
Ok, after a long debugging session, things are getting weird but somehow work ...
What I had to do:
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK DBUS_SESSION_BUS_ADDRESS
exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK DBUS_SESSION_BUS_ADDRESS
systemctl --user enable pipewire
systemctl --user stop xdg-desktop-portal
/nix/store/9bj2y7s0i6pncrh8ijkllyiyrz8yfbqq-xdg-desktop-portal-1.8.0/libexec> ./xdg-desktop-portal -v -r
/nix/store/sx9xfqxic42q2d61k3hk8f7d6ylrgx8v-xdg-desktop-portal-gtk-1.8.0/libexec> ./xdg-desktop-portal-gtk --replace --verbose
/nix/store/fxhs00lfclai4p40xgslm8gm2b10w3dy-xdg-desktop-portal-wlr-0.1.0/libexec> ./xdg-desktop-portal-wlr -l DEBUG -o DP-2
And now screen sharing ... works? And: After I did all this, the font rendering for NEW windows seems to be fixed. I don't understand why. Something is really really wrong and this is not the nix way of doing stuff.
I wrote the following "nix package" and start it via sway. If I reload the sway config (via super+shift+c), it also fixes font rendering in waybar.
xdg.nix
{ config, pkgs, ... }:
let
xdg-fix = pkgs.writeScriptBin "xdg-fix.sh" ''
#!${pkgs.bash}/bin/sh
${pkgs.systemd}/bin/systemctl --user stop xdg-desktop-portal
${pkgs.procps}/bin/pkill xdg-desktop-portal
${pkgs.procps}/bin/pkill xdg-desktop-portal-gtk
${pkgs.procps}/bin/pkill xdg-desktop-portal-wlr
${pkgs.xdg-desktop-portal}/libexec/xdg-desktop-portal -v -r &
${pkgs.xdg-desktop-portal-gtk}/libexec/xdg-desktop-portal-gtk --replace --verbose &
${pkgs.xdg-desktop-portal-wlr}/libexec/xdg-desktop-portal-wlr -l DEBUG -o DP-2 &
'';
in
{
environment.systemPackages = [
xdg-fix
];
}
and in .config/sway/config:
exec_always /run/current-system/sw/bin/xdg-fix.sh
And now screen sharing ... works?
I did your steps, and got it working for the first time... I'd been trying for months.
Got an error tho for ./xdg-desktop-portal-wlr -l DEBUG
tho:
[ERROR] - dbus: failed to acquire service name: File exists
Screen sharing seems to work file after commenting out GTK stuff:
xdg.portal = {
enable = true;
#gtkUsePortal = true;
extraPortals = with pkgs; [
xdg-desktop-portal-wlr
#xdg-desktop-portal-gtk
];
};
@gytis-ivaskevicius I will try. How do you start chromium?
@Kazimazi its broken for me again. I don't know why.
In case anyone's interested to test this: #114979 (but be aware that chromium
takes very long to build and that you need to cherry-pick (at least) 9f38162b3033a57f114e7601df95f257e94eb002
if you test on nixos-unstable
).
Switching to PipeWire 0.3 might help with this issue but it shouldn't magically fix those GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface ...
errors.
I briefly tested #114979 and it worked for me after the following hack (hope the other stuff that I've tried before isn't relevant...):
$ xdg-desktop-portal --replace --verbose
$ # In my case:
$ # /nix/store/bmhnz3q8j61gbxpvm67vb41f2n6639j8-xdg-desktop-portal-1.8.1/libexec/xdg-desktop-portal -v -r
Anyway, that's a dirty hack and no proper solution but maybe it helps someone in the meantime.
The real problem should be in nixos/modules/config/xdg/portal.nix
or pkgs/development/libraries/xdg-desktop-portal/default.nix
as apparently at least the following DBus interface doesn't get installed/registered correctly:
/nix/store/bmhnz3q8j61gbxpvm67vb41f2n6639j8-xdg-desktop-portal-1.8.1/share/dbus-1/interfaces/org.freedesktop.impl.portal.ScreenCast.xml
Errors (journalctl, nixos-version: 0aeba64fb26e4defa0842a942757144659c6e29f):
Mar 04 17:23:58 quorra .xdg-desktop-po[4401]: A backend call failed: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.impl.portal.ScreenCast” on object at path /org/freedesktop/portal/desktop
Mar 04 17:23:58 quorra .xdg-desktop-po[4401]: Failed to close session implementation: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.impl.portal.Session” on object at path /org/freedesktop/portal/desktop/session/1_2/webrtc_session448426574
(cc @worldofpeace (module) @jtojnar (package): FYI, in case you have time and motivation.)
I leave comment here to get news.
You don't have to. You can subscribe to issues (currently top-right in the UI), without adding an (arguably) pointless comment.
Just to add a datapoint here: I use Firefox and screen sharing on sway (nixos-unstable) does not work ootb, but suggested by @primeos "hack" (/path/to/xdg-desktop-portal -v -r
) works -- thanks a lot, @primeos! (I spent hell a lot of time before found this). I also seem to have to restart the portal-wlr and portal services first: after logining in sway I have portal-wlr dead for some reason (after a manual restart it's ok), and because of that portal has some issues (again, after restarting both, seem to work ok).
Needless to say, I would be very grateful if someone could fix this.
Just to add a datapoint here: I use Firefox and screen sharing on sway (nixos-unstable) does not work ootb, but suggested by @primeos "hack" (
/path/to/xdg-desktop-portal -v -r
) works -- thanks a lot, @primeos! (I spent hell a lot of time before found this). I also seem to have to restart the portal-wlr and portal services first: after logining in sway I have portal-wlr dead for some reason (after a manual restart it's ok), and because of that portal has some issues (again, after restarting both, seem to work ok).Needless to say, I would be very grateful if someone could fix this.
different case in mine, I just need to enable portal in config(tho I didn't check what's that options doing)
xdg.portal.enable = true;
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-wlr ];
environment.sessionVariables = {
MOZ_ENABLE_WAYLAND = "1";
XDG_CURRENT_DESKTOP = "sway"; # https://github.com/emersion/xdg-desktop-portal-wlr/issues/20
XDG_SESSION_TYPE = "wayland"; # https://github.com/emersion/xdg-desktop-portal-wlr/pull/11
};
and then replace the running portal with wlr version
/nix/store/v09agnrh58lgxyrpja0ajn30804jhmib-xdg-desktop-portal-wlr-e103e120e20e83acec5b66ce4cd33a0eb86df0b0/libexec/xdg-desktop-portal-wlr -r
Just to add a datapoint here: I use Firefox and screen sharing on sway (nixos-unstable) does not work ootb, but suggested by @primeos "hack" (
/path/to/xdg-desktop-portal -v -r
) works -- thanks a lot, @primeos! (I spent hell a lot of time before found this). I also seem to have to restart the portal-wlr and portal services first: after logining in sway I have portal-wlr dead for some reason (after a manual restart it's ok), and because of that portal has some issues (again, after restarting both, seem to work ok). Needless to say, I would be very grateful if someone could fix this.different case in mine, I just need to enable portal in config(tho I didn't check what's that options doing)
xdg.portal.enable = true; xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-wlr ]; environment.sessionVariables = { MOZ_ENABLE_WAYLAND = "1"; XDG_CURRENT_DESKTOP = "sway"; # https://github.com/emersion/xdg-desktop-portal-wlr/issues/20 XDG_SESSION_TYPE = "wayland"; # https://github.com/emersion/xdg-desktop-portal-wlr/pull/11 };
and then replace the running portal with wlr version
/nix/store/v09agnrh58lgxyrpja0ajn30804jhmib-xdg-desktop-portal-wlr-e103e120e20e83acec5b66ce4cd33a0eb86df0b0/libexec/xdg-desktop-portal-wlr -r
this will make it works on every apps/packages, firefox, chromium, obs, etc.
@ahdyt thanks! It's close to what I described, and I just checked: indeed, no need to restart services manually. The issue though is that it's clearly very user-unfriendly because I need to know the store path, which will be changing after every update.
@ahdyt thanks! It's close to what I described, and I just checked: indeed, no need to restart services manually. The issue though is that it's clearly very user-unfriendly because I need to know the store path, which will be changing after every update.
Just create a script package like what d4g done previously in above comment
@ahdyt that's a great point, thank you! I missed that comment completely. One thing though: if I create a file like that (e.g. xdg.nix
), how do I make sure I have the module available under /run/current-system/sw/bin
? Is it something like nix-env ??? xdg.nix
? I tried several things but they all failed (Sorry, I'm a NixOS newbie)
@ulysses4ever Just import the file in your configuration.nix,
configuration.nix
{ config, pkgs, ... }:
{
imports = [ ./xdg.nix ];
# ...
}
Then rebuild..
It appears to me that systemctl --user restart xdg-desktop-portal-wlr
is enough. Still feels like a bug.
Hey fellow Nixers, Can yall do me a favor and take a look at this comment I wrote <3 https://github.com/flathub/com.discordapp.Discord/issues/89#issuecomment-836191568 (And yes, it is related to screen sharing)
Latest unstable nixos channel with:
xdg.portal.enable = true;
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-wlr ];
xdg.portal.gtkUsePortal = true;
.zlogin:
if [ "$(tty)" = "/dev/tty1" ]; then
export MOZ_ENABLE_WAYLAND=1
export WLR_DRM_NO_MODIFIERS=1
export XDG_CURRENT_DESKTOP=sway
export XDG_SESSION_TYPE=wayland
exec sway 2> /tmp/sway.debug.log
fi
systemctl --user restart xdg-desktop-portal-wlr.service
Job for xdg-desktop-portal-wlr.service failed because the control process exited with error code.
See "systemctl --user status xdg-desktop-portal-wlr.service" and "journalctl --user -xe" for details.
journalctl --user -xe
Mai 10 14:32:12 ida systemd[1215]: Starting Portal service (wlroots implementation)...
░░ Subject: Unit UNIT has begun start-up
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ Unit UNIT has begun starting up.
Mai 10 14:32:12 ida xdg-desktop-portal-wlr[12204]: 2021/05/10 14:32:12 [ERROR] - wayland: failed to connect to display
Mai 10 14:32:12 ida systemd[1215]: xdg-desktop-portal-wlr.service: Main process exited, code=exited, status=1/FAILURE
Mai 10 14:32:12 ida systemd[1215]: xdg-desktop-portal-wlr.service: Failed with result 'exit-code'.
Mai 10 14:32:12 ida systemd[1215]: Failed to start Portal service (wlroots implementation).
░░ Subject: Unit UNIT has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ Unit UNIT has failed.
░░
░░ The result is RESULT.
@chaoflow that's unfortunately Sway specific (xdg-desktop-portal-wlr ... [ERROR] - wayland: failed to connect to display
), see https://github.com/NixOS/nixpkgs/issues/119445#issuecomment-820507505.
tl;dr: Adding both exec dbus-update-activation-environment WAYLAND_DISPLAY
and exec systemctl --user import-environment WAYLAND_DISPLAY
to your Sway configuration should fix it but we don't (yet) have a proper solution for Nixpkgs.
@chaoflow that's unfortunately Sway specific (
xdg-desktop-portal-wlr ... [ERROR] - wayland: failed to connect to display
), see #119445 (comment).tl;dr: Adding both
exec dbus-update-activation-environment WAYLAND_DISPLAY
andexec systemctl --user import-environment WAYLAND_DISPLAY
to your Sway configuration should fix it but we don't (yet) have a proper solution for Nixpkgs.
@primeos Thanks. With that xdg-desktop-portal-wlr is started again. However, screen sharing is still broken. That's #121678
Note: documentation on import-environment
and dbus-update-activation-environment
got ?recently? added to the swaywiki: https://github.com/swaywm/sway/wiki#gtk-applications-take-20-seconds-to-start, if your pavucontrol or any other application is very slow at starting up this is happening because of that commands missing.
I'm really happy that screensharing is finally working reliable.
For Sway users: While working on a PR I've noticed https://github.com/emersion/xdg-desktop-portal-wlr/commit/884a2e808e390a75137d68efe14521e2db38bc8e. I guess this might be the reason why it required hacks like running xdg-desktop-portal -v -r
. I've added that to my PR #123034 and with that I didn't need to execute/restart anything manually. Feel free to test/reproduce (either need to copy the XDG_CURRENT_DESKTOP
to your Sway configuration or add include /etc/sway/config.d/*
which we've only added recently in #122605) and feedback is welcome.
For Sway users: While working on a PR I've noticed emersion/xdg-desktop-portal-wlr@884a2e8. I guess this might be the reason why it required hacks like running
xdg-desktop-portal -v -r
. I've added that to my PR #123034 and with that I didn't need to execute/restart anything manually. Feel free to test/reproduce (either need to copy theXDG_CURRENT_DESKTOP
to your Sway configuration or addinclude /etc/sway/config.d/*
which we've only added recently in #122605) and feedback is welcome.
Can't wait to have this in the nixos documentation, so that people can follow just easily, not everyone following from the beginning, and yes, without the hack to restart the portal ofc.
Something seems to be wrong in the plasma5 session too. Screen sharing / recording fails with: org.freedesktop.impl.portal.desktop.kde[25197]: xdp-kde-screencast: zkde_screencast_unstable_v1 does not seem to be available
Also it looks like there is no xdg-desktop-portal-kde
user service at all, only the base xdg-desktop-portal
service even though the plasma module explicitly adds the kde portal to extraPortals.
https://github.com/NixOS/nixpkgs/pull/148344 fixes screensharing with firefox and obs, but not with chromium. Even with the fix there is no xdg-desktop-portal-kde user service and I don't think there should be.
Could anybody summarise what the status in NixOS 21.11 is?
Is screen sharing (individual-window, and whole-screen respectively) supposed/reported to work in Firefox and Chromium?
From my tests on plasma wayland on unstable:
Describe the bug I'm trying to use the pipewire support in Chromium to do screensharing on Wayland. I have gotten this working on other distros. However on nix, xdg-desktop-portal segfaults. Here is a backtrace:
To Reproduce Steps to reproduce the behavior:
chrome://flags
and enable the pipewire RTC support (only available in unstable currently).As I'm on 20.03, I have this module to enable xdg-desktop-portal with debug symbols:
If on unstable you can just use the
xdg.portal
module.Expected behavior Screen sharing should work.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
Notify maintainers
@jtojnar
Metadata
"x86_64-linux"
Linux 5.6.18, NixOS, 20.03.2262.2b417708c28 (Markhor)
yes
yes
nix-env (Nix) 2.3.6
"home-manager-20.03, nixos-20.03.2262.2b417708c28, nixos-unstable-20.09pre230335.9480bae3370"
/nix/var/nix/profiles/per-user/root/channels/nixos
Maintainer information: