KDE, xdg portal not working at all

For whatever reason, the kdePackages.xdg-desktop-portal will not start with this configuration. I’ve tried everything I could find but it seems that I’m the first person with this specific problem. Here is the current configuration:

# manager.nix
{ pkgs, ... }: {
  imports = [
    ./plasma.nix
    ./hyprland.nix
  ];

  # X11
  services.xserver = {
    enable = false;
    xkb = {
        layout = "it";
        variant = "";
    };
  };

  # UWSM
  programs.uwsm.enable = true;

  # SDDM
  services.displayManager.sddm = {
    enable = true;
    wayland.enable = true;
    theme = "breeze";
  };

  # Portals
  xdg.portal = {
    enable = true;
    extraPortals = with pkgs; [
      xdg-desktop-portal-gtk
    ];
  };

  # Desktop enviroments
  plasma.enable = true;
  hyprland.enable = true;
}
# plasma.nix
{ pkgs, lib, config, ... }: {
  options = {
    plasma.enable = lib.mkEnableOption "Enables the KDE Plasma 6 desktop environment";
  };

  config = lib.mkIf config.plasma.enable {
    # Plasma
    services.desktopManager.plasma6.enable = true;
    environment.plasma6.excludePackages = with pkgs.kdePackages; [
      elisa
      xwaylandvideobridge
      plasma-browser-integration
    ];

    # Portals
    xdg.portal.extraPortals = with pkgs.kdePackages; [
      xdg-desktop-portal-kde
    ];

    # Packages
    environment.systemPackages = with pkgs.kdePackages; [
      kate
      filelight
      discover
    ];
  };
}

This configuration, and every other variant that comes to mind, will install the kdePackages.xdg-desktop-portal-kde, but fail to start it. This is the output of systemctl --user status plasma-xdg-desktop-portal-kde.service:

○ plasma-xdg-desktop-portal-kde.service - Xdg Desktop Portal For KDE
     Loaded: loaded (/home/leo/.config/systemd/user/plasma-xdg-desktop-portal-kde.service; linked; preset: ignored)
     Active: inactive (dead)

P.S.

I’ve tried putting the xdg.portal.extraPackages and xdg.portal.enable everywhere, but with the same result. It’s very likely not a problem with the location of the statements. I know the configuration may seem weird at first and that could be the problem, but I assure you it isn’t. I noticed this problem when I was using the zed-editor program, to modify my configuration. I tried opening another folder and it hit me with a Couldn't open file picker due to missing xdg-desktop-portal implementation..

Yes, I have problems with that too and I also use Plasma 6, probably this only occurs there.

I can see the following entry in the log:
xdg-desktop-portal.service: start operation timed out. Terminating.

This also slows down my browser startup extremely.
Has anyone found a solution for this?

This is my systemctl --user status xdg-desktop-portal.service:

● xdg-desktop-portal.service - Portal service
     Loaded: loaded (/etc/systemd/user/xdg-desktop-portal.service; linked-runtime; preset: ignored)
     Active: active (running) since Tue 2025-05-27 20:55:39 CEST; 2min 6s ago
 Invocation: 945901b22d874644b324ed654fa87210
   Main PID: 2236 (.xdg-desktop-po)
      Tasks: 5 (limit: 18633)
     Memory: 5M (peak: 5.9M)
        CPU: 75ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/xdg-desktop-portal.service
             └─2236 /nix/store/xj7wqhp8vkl7yw5q5pq862qjm0j23cfd-xdg-desktop-portal-1.20.0/libexec/xdg-desktop-portal

mag 27 20:55:38 hermes systemd[2172]: Starting Portal service...
mag 27 20:55:39 hermes systemd[2172]: Started Portal service.
mag 27 20:55:40 hermes .xdg-desktop-po[2236]: Realtime error: Could not get pidns: Could not fstatat ns/pid: Not a directory
mag 27 20:55:40 hermes .xdg-desktop-po[2236]: Realtime error: Could not get pidns: Could not fstatat ns/pid: Not a directory
mag 27 20:55:40 hermes .xdg-desktop-po[2236]: Realtime error: Could not get pidns: Could not fstatat ns/pid: Not a directory
mag 27 20:55:40 hermes .xdg-desktop-po[2236]: Realtime error: Could not get pidns: Could not fstatat ns/pid: Not a directory
mag 27 20:55:40 hermes .xdg-desktop-po[2236]: Realtime error: Could not get pidns: Could not fstatat ns/pid: Not a directory
mag 27 20:55:41 hermes .xdg-desktop-po[2236]: Realtime error: Could not get pidns: Could not fstatat ns/pid: Not a directory

I guess my problem is a little different from yours, although we’re in the same situation. I’ve also updated my nix config (with no success). This is the current portal configuration:

# portals.nix
{inputs, pkgs, ...}:
let
  hyprlandPackages = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system};
in {
  xdg.portal = {
    enable = true;

    config = {
      kde.default = [ "kde" "gtk" "gnome" ];
      kde."org.freedesktop.portal.FileChooser" = [ "kde" ];

      hyprland.default = [ "hyprland" "gtk" "termfilechooser" ];
      hyprland."org.freedesktop.portal.FileChooser" = [ "termfilechooser" ];
    };

    extraPortals = [
      pkgs.xdg-desktop-portal-gtk
      pkgs.xdg-desktop-portal-gnome
      pkgs.xdg-desktop-portal-termfilechooser

      pkgs.kdePackages.xdg-desktop-portal-kde
      hyprlandPackages.xdg-desktop-portal-hyprland
    ];
  };
}

It creates all the files and everything inside the /etc/xdg/xdg-desktop-portal/*-portals.conf but I’m still getting errors from applications trying to use the dolphin file chooser.

I can confirm that if I only use xfce, everything starts without any problems!

Had the same issue with having both kde and gtk portals enabled. Removing the gtk portal (and a spurious gtk.enable = true somewhere else in my config).

The location of your statements indeed does not matter, as they are modules that are imported with the imports keyword; hence the content of all modules will be merged. Double check in your hyprland.nix if you don’t have any gtk-related business?

Some updates here, as I’m currently configuring hyprland:

  • on hyprland the portals work, although not the filechooser one. I’ve tried overriding it with the xdg-desktop-portal-termfilechooser, but that doesn’t seem to work.

  • on kde, I tried screensharing on discord, “maybe zed was bugged all along”, but instead the portal interface that let’s you select the monitor stopped working and no longer functions. For clarity, on the hyprland side it works just fine.

The current situation

# bundle.nix
{...}: {
  imports = [
    ./portals.nix
    ./manager.nix
    ./plasma.nix
    ./hyprland.nix
  ];

  # X11
  services.xserver = {
    enable = false;
    xkb = {
        layout = "it";
        variant = "";
    };
  };

  # UWSM
  programs.uwsm.enable = true;

  # Desktop enviroments
  plasma.enable = true;
  hyprland.enable = true;
}
# portals.nix
{inputs, pkgs, ...}:
let
  hyprlandPackages = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system};
in {
  xdg.portal = {
    enable = true;

    config = {
      kde.default = [ "kde" "gtk" "gnome" ];
      kde."org.freedesktop.portal.FileChooser" = [ "kde" ];
      kde."org.freedesktop.portal.OpenURI" = [ "kde" ];

      hyprland.default = [ "hyprland" "gtk" "termfilechooser" ];
      hyprland."org.freedesktop.portal.FileChooser" = [ "termfilechooser" ];
      hyprland."org.freedesktop.portal.OpenURI" = [ "termfilechooser" ];
    };

    extraPortals = [
      pkgs.xdg-desktop-portal-gtk
      pkgs.xdg-desktop-portal-gnome
      pkgs.xdg-desktop-portal-termfilechooser

      pkgs.kdePackages.xdg-desktop-portal-kde
      hyprlandPackages.xdg-desktop-portal-hyprland
    ];
  };
}
# manager.nix
{...}: {
  services.displayManager.sddm = {
    enable = true;
    wayland.enable = true;
    theme = "breeze";
  };
}
# plasma.nix
{pkgs, lib, config, ...}: {
  options = {
    plasma.enable = lib.mkEnableOption "Enables Plasma 6";
  };

  config = lib.mkIf config.plasma.enable {
    # Plasma
    services.desktopManager.plasma6.enable = true;
    environment.plasma6.excludePackages = with pkgs.kdePackages; [
      elisa
      xwaylandvideobridge
      plasma-browser-integration
    ];

    # Packages
    environment.systemPackages = with pkgs.kdePackages; [
      kate
      filelight
      discover
    ];
  };
}
# hyprland.nix
{inputs, pkgs, lib, config, ...}:
let
  hyprlandPackages = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system};
in {
  options = {
    hyprland.enable = lib.mkEnableOption "Enables Hyprland";
  };

  config = lib.mkIf config.hyprland.enable {
    # Hyprland
    programs.hyprland = {
      enable = true;
      withUWSM = true;

      package = hyprlandPackages.hyprland;
      portalPackage = hyprlandPackages.xdg-desktop-portal-hyprland;
    };

    # Packages
    environment.systemPackages = with pkgs; [
      alacritty
      bemenu
      lf
    ];
  };
}

Status: not working

another edit: something changed somehow:

● xdg-desktop-portal.service - Portal service
     Loaded: loaded (/etc/systemd/user/xdg-desktop-portal.service; linked-runtime; preset: ignored)
     Active: active (running) since Tue 2025-05-27 22:05:46 CEST; 12min ago
 Invocation: 430003b62d76488baedd60352c4b8418
   Main PID: 22407 (.xdg-desktop-po)
      Tasks: 5 (limit: 18633)
     Memory: 3.1M (peak: 3.9M)
        CPU: 73ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/xdg-desktop-portal.service
             └─22407 /nix/store/xj7wqhp8vkl7yw5q5pq862qjm0j23cfd-xdg-desktop-portal-1.20.0/libexec/xdg-desktop-portal

mag 27 22:05:46 hermes systemd[2190]: Starting Portal service...
mag 27 22:05:46 hermes systemd[2190]: Started Portal service.

No more Realtime error: Could not get pidns: Could not fstatat ns/pid: Not a directory error on the xdg-desktop-portal service

another another edit: on hyprland, the hyprland portal works, but the gtk and termfilechooser no, on kde no portal is active whatsoever. Maybe there’s an issue with the xdg.portal.config?

I love xfce, but that isn’t a solution unfortunately.

I saw I got tagged on another post with the same issue. No fix has been found yet, so that’s kinda concerning tbh. One probable issue, I believe, is related with the xdg.portal.config. All it does is generate some files that are clearly ignored by portals, so this would need to be fixed or at least troubleshooted. If anyone that stumbles upon this posts has contacts with actual nixos devs or expert, so that this issue could be solved once and for all, that would be great.

1 Like

Update

Idk how it got fixed. Yesterday after using hyprland I got mad at some bluetooth issues and decided to disable hyprland on my configuration. I hoped maybe that was the problem all along, but removing and rebooting the system didn’t do anything. Now I just woke up, opened my laptop and tried streaming on discord. Everything worked. Not only that but the xdg.portal.config started working somehow.

ts makes no sense, and kinda pmo.

I slightly changed my configuration so that might be the solution, but it seems just so weird to me.

# bundle.nix
{...}: {
  imports = [
    ./portals.nix
    ./manager.nix
    ./plasma.nix
    ./hyprland.nix
  ];

  # X11
  services.xserver = {
    enable = false;
    xkb = {
        layout = "it";
        variant = "";
    };
  };

  # Desktop enviroments
  plasma.enable = true;
  hyprland.enable = false;
}
# manager.nix
{...}: {
  services.displayManager.sddm = {
    enable = true;
    wayland.enable = true;
    theme = "breeze";
  };
}
# portals.nix
{pkgs, ...}: {
  xdg.portal = {
    enable = true;

    extraPortals = with pkgs; [
      xdg-desktop-portal-gtk
      xdg-desktop-portal-gnome
    ];
  };
}
# plasma.nix
{pkgs, lib, config, ...}: {
  options = {
    plasma.enable = lib.mkEnableOption "Enable Plasma 6";
  };

  config = lib.mkIf config.plasma.enable {
    # Plasma
    services.desktopManager.plasma6.enable = true;
    environment.plasma6.excludePackages = with pkgs.kdePackages; [
      elisa
      xwaylandvideobridge
      plasma-browser-integration
      konsole
    ];

    # Portals
    xdg.portal = {
      config = {
        kde.default = [ "kde" "gtk" "gnome" ];
        kde."org.freedesktop.portal.FileChooser" = [ "kde" ];
        kde."org.freedesktop.portal.OpenURI" = [ "kde" ];
      };

      extraPortals = with pkgs.kdePackages; [
        xdg-desktop-portal-kde
      ];
    };

    # Packages
    environment.systemPackages = with pkgs.kdePackages; [
      kate
      filelight
      discover
    ];
  };
}
# hyprland.nix
{inputs, pkgs, lib, config, ...}:
let
  hyprlandPackages = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system};
in {
  options = {
    hyprland.enable = lib.mkEnableOption "Enable Hyprland";
  };

  config = lib.mkIf config.hyprland.enable {
    # UWSM
    programs.uwsm.enable = true;

    # Hyprland
    programs.hyprland = {
      enable = true;
      withUWSM = true;

      package = hyprlandPackages.hyprland;
      portalPackage = hyprlandPackages.xdg-desktop-portal-hyprland;
    };

    # Portals
    xdg.portal = {
      config = {
        hyprland.default = [ "hyprland" "gtk" "gnome" "termfilechooser" ];
        hyprland."org.freedesktop.portal.FileChooser" = [ "termfilechooser" ];
        hyprland."org.freedesktop.portal.OpenURI" = [ "termfilechooser" ];
      };

      extraPortals = with pkgs; [
        hyprlandPackages.xdg-desktop-portal-hyprland
        xdg-desktop-portal-termfilechooser
      ];
    };

    # Packages
    environment.systemPackages = with pkgs; [
      tofi
      lf
      swww
      ncpamixer
    ];
  };
}

Hope this helps you, if you’ve got this problem.

I have noticed that it does not work directly after a restart. If I wait a few minutes, it seems to work again.