From 1c9e470ff6f5a6fcef1e1ecb13f45f7fc634a6b0 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 1 Jun 2026 00:11:19 -0700 Subject: [PATCH] hyprland: start portal backends on dbus activation --- nixos/hyprland.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/nixos/hyprland.nix b/nixos/hyprland.nix index 0a5ea759..42bb01f5 100644 --- a/nixos/hyprland.nix +++ b/nixos/hyprland.nix @@ -149,6 +149,7 @@ overrideAttrs = f: makeHyprlandLuaPackage (package.overrideAttrs f); }; hyprlandPackage = makeHyprlandLuaPackage baseHyprlandPackage; + hyprlandPortalPackage = config.programs.hyprland.portalPackage; hyprlandGapsEnabledString = if config.myModules.hyprland.gaps.enable then "1" @@ -505,6 +506,36 @@ [Service] ExecStopPost=${cleanupStaleGraphicalSession} ''; + + # File chooser requests from early-started Electron apps go through + # xdg-desktop-portal-gtk. The upstream portal backend units wait for + # graphical-session.target, which UWSM can reach well after Wayland + # and D-Bus are already usable. That makes D-Bus activation time out + # and can abort the requesting app. + xdg.configFile."systemd/user/xdg-desktop-portal-gtk.service".text = '' + [Unit] + Description=Portal service (GTK/GNOME implementation) + PartOf=graphical-session.target + + [Service] + Type=dbus + BusName=org.freedesktop.impl.portal.desktop.gtk + ExecStart=${pkgs.xdg-desktop-portal-gtk}/libexec/xdg-desktop-portal-gtk + ''; + + xdg.configFile."systemd/user/xdg-desktop-portal-hyprland.service".text = '' + [Unit] + Description=Portal service (Hyprland implementation) + PartOf=graphical-session.target + ConditionEnvironment=WAYLAND_DISPLAY + + [Service] + Type=dbus + BusName=org.freedesktop.impl.portal.desktop.hyprland + ExecStart=${hyprlandPortalPackage}/libexec/xdg-desktop-portal-hyprland + Restart=on-failure + Slice=session.slice + ''; } ) ];