Can't install xdg-desktop-portal-hyprland from flake

I am trying to install xdg-desktop-portal-hyprland from the hyprland flake. The reason for this is that the startup time for all gtk apps is really slow (2-4 seconds). But when I rebuild, the portal is compiled whithout errors but at the end I get a linking error:

user-units> ln: failed to create symbolic link '/nix/store/442lzr8p7bs0pnwq444j4241cmgkv5cp-user-units/xdg-desktop-portal-hyprland.service': File exists
error: builder for '/nix/store/jmviwg1wj3qcqrdw381g8qiynfbq6fgd-user-units.drv' failed with exit code 1;
       last 1 log lines:
       > ln: failed to create symbolic link '/nix/store/442lzr8p7bs0pnwq444j4241cmgkv5cp-user-units/xdg-desktop-portal-hyprland.service': File exists
       For full logs, run 'nix log /nix/store/jmviwg1wj3qcqrdw381g8qiynfbq6fgd-user-units.drv'.
error: 1 dependencies of derivation '/nix/store/0jrmq7wvs5lbjsz7877xb3div4sx3fn4-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/xfsdbwzkq26xahjjyfibb5frrwpl134h-nixos-system-desktop-25.05.20241219.d70bd19.drv' failed to build
┏━ 1 Errors:
┃ error: builder for '/nix/store/jmviwg1wj3qcqrdw381g8qiynfbq6fgd-user-units.drv' failed with exit code 1;
┃        last 1 log lines:
┃        > ln: failed to create symbolic link '/nix/store/442lzr8p7bs0pnwq444j4241cmgkv5cp-user-units/xdg-desktop-portal-hyprland.servi…
┃        For full logs, run 'nix log /nix/store/jmviwg1wj3qcqrdw381g8qiynfbq6fgd-user-units.drv'.
┣━ Dependency Graph:
┃       β”Œβ”€ βœ” unit-accounts-daemon.service ⏱ 3s
┃       β”‚  β”Œβ”€ βœ” X-Restart-Triggers-polkit ⏱ 3s
┃       β”œβ”€ βœ” unit-polkit.service ⏱ 3s
┃       β”œβ”€ βœ” unit-dbus.service ⏱ 1s
┃    β”Œβ”€ βœ” system-units ⏱ 1s
┃    β”‚           β”Œβ”€ βœ” system-path ⏱ 5s
┃    β”‚        β”Œβ”€ βœ” dbus-1 ⏱ 1s
┃    β”‚     β”Œβ”€ βœ” X-Restart-Triggers-dbus ⏱ 1s
┃    β”‚  β”Œβ”€ βœ” unit-dbus.service ⏱ 1s
┃    β”œβ”€ ⚠ user-units failed with exit code 1 after ⏱ 0s
┃ β”Œβ”€ ⏸ etc
┃ ⏸ nixos-system-desktop-25.05.20241219.d70bd19
┣━━━ Builds           β”‚ Downloads        β”‚ Host
┃        β”‚ βœ” 27 β”‚     β”‚     β”‚      β”‚     β”‚ localhost
┃        β”‚      β”‚     β”‚     β”‚ ↓ 93 β”‚     β”‚ https://cache.nixos.org
┗━ βˆ‘ ⏡ 0 β”‚ βœ” 27 β”‚ ⏸ 2 β”‚ ↓ 0 β”‚ ↓ 93 β”‚ ⏸ 0 β”‚ ⚠ Exited after 1 build failures at 10:54:14 after 4m43s
Error:
   0: Command exited with status Exited(1)

Here is how I try to install the portal:

{ inputs, pkgs, ... }:
{
  programs.hyprland.enable = true;
  xdg.portal = {
    enable = true;
    wlr.enable = true;
    xdgOpenUsePortal = true;
    extraPortals = [
      pkgs.xdg-desktop-portal-gtk
      inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland
    ];
  };
}

Does anyone know what could cause this issue ?
And is that even something that could fix the slow gtk app startup time ?

First I would run nix log /nix/store/jmviwg1wj3qcqrdw381g8qiynfbq6fgd-user-units.drv, maybe you find more information there.

Secondly, just so that I understand this right, you hope to achieve better performance by using the xdg-desktop-portal-hyprland from the flake as opposed to the one that is in nixpkgs, right?

Lastly, I do not think that the steps you are trying to perform are necessary, as it seems that programs.hyprland already sets the portal for you. That could also be why the symlink fails.

First I would run nix log /nix/store/jmviwg1wj3qcqrdw381g8qiynfbq6fgd-user-units.drv, maybe you find more information there.

It just gives the same message:

ln: failed to create symbolic link  '/nix/store/442lzr8p7bs0pnwq444j4241cmgkv5cp-user-units/xdg-desktop-portal-hyprland.service': File exists 

Secondly, just so that I understand this right, you hope to achieve better performance by using the xdg-desktop-portal-hyprland from the flake as opposed to the one that is in nixpkgs, right?

Yes I wanted to test if there was a difference in performance (although I don’t relay know how to measure that tbh)
I just put back the portal from nixpkgs and it works fine, but I don’t know what I could do about the gtk app startup time. Before it was not that bothering but since I started using ghostty as my terminal this became much more annoying.
Do you have an idea on what could case such a problem ?

Regarding performance, I am not really sure to be honest, but I also do not run hyprland and have never timed my apps between different versions (on sway).

On the symlink issue, I would try removing the package from xdg.portal.extraPortals and instead add it to programs.hyprland.portalPackage. What that does is adding the package to xdg.portal.extraPortals for you (see the link I posted above). The way you currently have this setup might result in xdg-desktop-portal-hyprland being added twice, which could cause the conflict. But I am not sure sadly.

1 Like