# Atomic responsibility: # - System-wide XDG basics # - System-wide xdg-desktop-portal + chosen backends # - A sane portals.conf selection (prevents “wrong backend” surprises) # # Notes: # - Keep ALL portal-related config here (do not also configure xdg.portal in wm-hyprland.nix). # - xdg.portal.config.common sets defaults via portals.conf(5) and is supported by NixOS. :contentReference[oaicite:0]{index=0} # - If you enable xdg.portal.wlr.enable elsewhere, it auto-adds xdg-desktop-portal-wlr to extraPortals. :contentReference[oaicite:1]{index=1} # (We do NOT do that here because Hyprland typically uses xdg-desktop-portal-hyprland instead.) # - xdg-desktop-portal-gtk is commonly needed for OpenURI/FileChooser support. :contentReference[oaicite:2]{index=2} { config, lib, pkgs, ... }: { ########################################################################## # XDG basics (system) ########################################################################## xdg = { menus.enable = true; mime.enable = true; }; ########################################################################## # Portals (system) ########################################################################## xdg.portal = { enable = true; # Prefer Hyprland portal for compositor-integrated features (screensharing, etc), # and GTK for things like OpenURI/FileChooser compatibility. extraPortals = with pkgs; [ xdg-desktop-portal-hyprland xdg-desktop-portal-gtk ]; # Explicit portal routing via portals.conf (prevents “random backend chosen” issues). # This writes /etc/xdg/xdg-desktop-portal/portals.conf. :contentReference[oaicite:3]{index=3} config.common = { # Default backend order for interfaces where multiple backends exist. default = [ "hyprland" "gtk" ]; # (Optional, but often helpful) Ensure GTK handles common UX portals reliably. "org.freedesktop.impl.portal.FileChooser" = [ "gtk" ]; "org.freedesktop.impl.portal.OpenURI" = [ "gtk" ]; }; }; ########################################################################## # Environment defaults (system) ########################################################################## environment.sessionVariables = { # Encourage GTK apps to use portals for file picker / open-uri on Wayland. GTK_USE_PORTAL = "1"; # Desktop identity hints used by some apps / portal logic. # (Set once here; don’t duplicate in HM and NixOS.) XDG_CURRENT_DESKTOP = "Hyprland"; XDG_SESSION_DESKTOP = "Hyprland"; }; ########################################################################## # Optional: small, non-invasive tooling for troubleshooting ########################################################################## environment.systemPackages = with pkgs; lib.mkAfter [ xdg-utils ]; }