I had screen sharing working fine on hyprland, but then it stopped.
I tried looking through my flake, commit history to see what is could be, that have changed and found nothing.
Did @merrinx fix help you? I think his is only related to xwayland apps.
This week I had screen sharing break again for the xth time after update. It seems to happen quite often and is probably related to regressions introduced by incompatibilities in the desktop portal and Hyprland. I could sometimes fix it by taking different commits for those using overlays, but haven’t succeeded yet this time (only tried current master for both).
As I tried a lot of things, I can’t say for sure what the problem was. But it started working after I put pkgs.xdg-desktop-portal-gtk in extraPortals, here’s my config:
and you must ensure that the appropriate envvars are exported to the dbus/systemd user session.
Adding portals won’t really fix anything here; the hyprland portal should be taken care of by existing modules, and adding the gtk portal is irrelevant as it doesn’t provide screensharing capability (the hyprland portal is what provides that support).
Same goes for sway, though sway uses the wlr portal instead of course to provide screensharing support.
I also fail to see any relevance with enabling xwayland here, though you probably should want to enable it for other reasons.
You’re right that it’s not actually related to xwayland, or rather only if the scope described here applies, which for most won’t be the main issue.
For the rest I’m afraid it’s a bit more messy than that. Mind you, my issue was clearly a regression, i.e. it used to work with “some previous” commit of nixpkgs/nixos-unstable. The issue happened several times over months, each time without changing config. I do have (always had) the necessary basic settings enabled in my config.
Interestingly, using @gian 's portal config verbatim lead to only the gtk portal being put in $XDG_PORTAL_DIR, but only if I didn’t explicitly use the inputs.hyperland.{nixosModules,homeManagerModules}.default (which recently had been my standard, i.e. using everything hyprland from nixpkgs and not upstream.)
The Issue I’m in fact currently having is this one, which for me (at least on my intel GPU system, haven’t tried my AMD yetEDIT: on the AMD the problem does not exist this time) was not solved by the upstream fixes.
Annoyingly I couldn’t yet (easily) build, say, Hyprland v0.40.0 to test “last known good”, because pinning inputs to corresponding (older) commits gives me build failures, likely because of deps that “have moved on”, so it would require a more elaborate overlay or follows config.