I am running Cosmic, Hyprland, and Plasma.
When I login to Cosmic, it fails to find xdg.portal.config.COSMIC.
If I only run Cosmic it works fine.
I found the root cause to be that Hyprlands Home Manager modules unconditionally adds xdg-desktop-portal-hyprland to xdg.portal.extraPortals:
xdg.portal = {
enable = cfg.finalPortalPackage != null;
extraPortals = lib.mkIf (cfg.finalPortalPackage != null) [ cfg.finalPortalPackage ];
configPackages = lib.mkIf (cfg.finalPackage != null) (lib.mkDefault [ cfg.finalPackage ]);
};
This places a portal in a different directory that the other portals
/etc/profiles/per-user/rasmus/share:
īæ portals ó±» hyprland-portals.conf
/run/current-system/sw/share:
īæ portals ó±» cosmic-portals.conf ó±» hyprland-portals.conf ó±» kde-portals.conf
The problem is that when xdg-desktop-portal scans for portals it only searches the first directory it finds in XDG_DATA_DIRS.
The first it finds is Home Managers per user.
echo $XDG_DATA_DIRS
...:/etc/profiles/per-user/rasmus/share:...:/run/current-system/sw/share:...
However, it failes after not finding cosmic-portals.conf in /etc/profiles/per-user/rasmus/share.
systemctl --user stop xdg-desktop-portal.service ļ
XDG_CURRENT_DESKTOP=COSMIC G_MESSAGES_DEBUG=all \
/nix/store/vzkn1a38x6fg66qkn29pbfbvrlznjmjn-xdg-desktop-portal-1.20.4/libexec/xdg-desktop-portal 2>&1 &
This gives
load portals from /etc/profiles/per-user/rasmus/share/xdg-desktop-portal/portals
loading /etc/profiles/per-user/rasmus/share/xdg-desktop-portal/portals/hyprland.portal
Requested cosmic.portal is unrecognized
Requested gtk.portal is unrecognized
Workaround
I got it to work by placing cosmics portal in home manager.
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-cosmic ];
Discussion
Should the Hyprland HM module manage portals at all, given that it causes this split between per-user and system profiles?
And should xdg-desktop-portal scan all directories in XDG_DATA_DIRS for .portal files rather than stopping at the first directory that contains any?