Slow application startup

Newbie here

I installed NixOS a few days ago and I use Sway as my WM. The big problem is that every application has a really long startup time.
Take Nautilus (GNOME File Manager) as an example. It takes ~30-40 seconds to start. Same goes for Firefox, Steam, and pretty much every other program I have installed. This also is the case for flatpak applications.
I suspect it has something to do with the xdg-desktop-portal.

Here are my config files:

And here some program information:

I would be glad for any help or hint you might have. Thank you in advance.

It would be useful to know what kind of hardware you’re running on.

Do you have a persistent .cache/mesa_shader_cache/ directory? Programs require shaders compiling at first start, it can take a while (but certainly not so much time, but this would depend of your specs)

  • AMD Radeon RX6700XT
  • AMD Ryzen 9500X
  • AMD Ryzen 9 3900X
  • 16 GB Ram

I should have. I’m not home right now, I’ll check it out later.
Yes, I have a persistent .cache dir. It contains a mesa_shader_cache directory.

That’s not a real product :stuck_out_tongue: But it doesn’t matter; I was mostly asking in case you were running on either very weird or very old hardware. If that’s not the case then it’s very odd to have this problem.

Yes, I’m stupid. I actually use a 9 3900X :sweat_smile:

I found a temporary solution to this problem.
Where there was

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

I removed xdg-desktop-portal-gnome.
I now don’t have a desktop portal for GNOME apps (Nautilus, etc.) but applications start as expected. This is kind of weird, because using both desktop portals on Arch worked just fine for me. I will definitely look further into this.
Thank y’all for your replies.

Look in the env vars, IIRC there was a debug var to force portals that would cause insane load times when set.

We even had an option for it but we removed it because of that.

1 Like

I have the exact same issue as op, but I have a much simpler setup. I know sway can work well on this same machine because it did so before I reinstalled with a much simpler set of configs. Where before I had lots of stuff pulled in from gnome manually. This has simplified the config and everything works, except that every single app, including the terminal, takes at least 30 seconds to open. I now just have

    services.xserver = {
      enable = true;
      desktopManager.gnome.enable = true;
      displayManager.gdm.enable = true;
    };

Op’s bandaid fix doesn’t really apply to my config though.

Hey, I have the same problem on Plasma. @faffi did you ever found a fix?

Unfortunately I never found a fix for this problem and after encountering more issues (like Steam games not working correctly) I moved away from NixOS as my desktop operating system. I still love the build system and NixOS is still my linux distro of choice for servers.

Did anybody find a solution to this? I am running NixOS+Hyprland on a laptop with Intel iGPU+NVIDIA dGPU and I often need to wait 3–5 seconds for a terminal (alacritty/kitty) window to launch. After the initial launch, second and third window launches etc. are fine but every once in a while when I want to launch a new window after some time the first terminal window takes inconsistently and annoyingly a long time. I have xdg-desktop-portal-hyprland and xdg-desktop-portal-gtk installed.

Did you started dbus before starting your portals ? I had same problem and I have added the following to my hyprland config :

###Start dbus ###
exec-once = systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
### kill active portals and restart them ###
exec-once = $scriptsDir/PortalHyprland-NixOS.sh

The script to restart the portals Is here:

#!/run/current-system/sw/bin/bash

# Find all portals executables actually running
portal_list=$(ps -fu bt|grep xdg-desktop-portal|grep -v grep|sort|awk -F " " '{print $8}')

for portal in $portal_list; do
  # Get the name of executable
  portal_name=$(basename -- "$portal")

# Check if the executable is valid and exists
  if [ -x "$portal" ]; then
    # Kill the active one and restart it
    killall "$portal_name"
    sleep 1
    "$portal" &
    exit 0
  fi
done

# If no valid executable is found, report an error
echo "No valid xdg-portal-desktop found"
exit

The script could be improved, but it works for me. I have absolutely no delay after launching any apps.

Hope it helps.
Regards,
BT

I’m having the same issue.
I reinstalled nixos because I was trying out bazzite for a while.
Before the reinstall everything worked fine. Now with the exact same config I run into this problem.

My gnome config is also relatively simple like @senorsmile

{ pkgs, customPackages, ... }: {

  services.xserver = {
    enable = true;
    displayManager.gdm.enable = true;
    desktopManager.gnome.enable = true;
  };

  services.udev.packages = with pkgs; [ gnome-settings-daemon ];
  programs.dconf.enable = true;

  environment.systemPackages = with pkgs; [
    adwaita-icon-theme
    adwaita-icon-theme-legacy
  ];
}

Any help regarding that would be much appreciated

The issue went away when I upgraded to 23.11. I haven’t experienced anything like it since. I don’t know if this is of any help, but these are some of the additional things I’ve added at some point in the last year that are possibly related:

  programs.sway = {
    enable = true;             
    wrapperFeatures.gtk = true; # so that gtk works properly
    # remaining irrelevant removed
  }

  environment.sessionVariables = {
    # enable wayland automatically in apps like chrome
    NIXOS_OZONE_WL = "1";
  };

  environment.pathsToLink = [ "/libexec" ]; # enable polkit 
  
  services.gvfs.enable = true; 
  
  services.gnome.gnome-keyring.enable = true;
  
  programs.dconf.enable = true;


  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.utf8";
  i18n.extraLocaleSettings = {
    LC_ADDRESS = "en_US.UTF-8";
    LC_IDENTIFICATION = "en_US.UTF-8";
    LC_MEASUREMENT = "en_US.UTF-8";
    LC_MONETARY = "en_US.UTF-8";
    LC_NAME = "en_US.UTF-8";
    LC_NUMERIC = "en_US.UTF-8";
    LC_PAPER = "en_US.UTF-8";
    LC_TELEPHONE = "en_US.UTF-8";
    LC_TIME = "en_US.UTF-8";
  };

Thanks for the quick reply! Much appreciated. I have most of that stuff (minus sway) set already.
No idea why this is happening now when it was working before. Welp…

When I had the issue, it was specifically a problem inside of sway when gnome/gdm were installed. If I removed them and logged into sway manually, the issue went away. If I logged directly into gnome (which I would never use; I just install it to get all the goodies it comes with by default, and as a backup), apps would not see the slow down.

So, it’s possible that whatever you’re experiencing now is in fact different than the bug previously mentioned which seems to have been resolved.

Most likely, yeah. I switched back to bazzite for now. Everything just works on that distro. But I drank the nixos kool aid. I know I will be back at some point. Maybe it will be resolved by then.