Plasma slow opening KDE apps and tasks

Hey there, I’m new to nixOS and it’s great so far, but I have this strange issue.
When opening KDE apps, like Dolphin and Konsole, nixOS is slow.

On any other distro I used they used to open instantly, but here they takes something like 3-4 seconds. The delay is not huge so it’s not something unbearable, though it’s enough to tell that something is off.

At first I thought that it may be related to the way nixOS manages paths, but I noticed two strange things: one is that it’s always slower right after login, the other is that if I open one of these apps, close it and right after I reopen it, then it is instant. So this delay is not constant and it’s mitigated by opening another instance of the app right after closing it.

For example, if I open Konsole, at first is often slow, but if I spam my shortcut to it the instances after the second one are fast.

The same thing happens when switching virtual desktops. If I do it, it’s laggy. If I do it again right after, it’s smooth. My guess was that it could have something to do with my nvidia card but I seriously doubt it.

I thought that maybe the system somehow fails to load some libraries correctly, but I’m really trying to guess here, I really have no idea what’s going on.
I’m not sure which log or config would be useful here, let me know if I can provide something handy to troubleshoot it.
My configuration.nix has nothing special in it, just the defaults. System usage seems fine and launching these apps from terminal shows nothing useful.

I’d be very grateful if someone could help me here.

1 Like

That’s quite long.

We do have some inefficiencies around the way we start executables (see Making RUNPATH redundant for Nix | Farid Zakaria’s Blog) but these should not usually cause this significant of a difference.

Just a hunch but what’s your CPU scheduling governor?

A couple things start up in the background after login. If apps are significantly slower to start up during this phase, that indicates an I/O bottleneck to me which isn’t surprising.

This is a textbook example of caching. The kernel keeps stuff it’s read from the (relatively speaking) slow disk into otherwise unused memory and reads it from there the next time.

If caching helps, this is further evidence for an I/O bottleneck.

This might again be caching but could also be memory/swap or GPU related.

1 Like

Are you using stable or unstable, or flakes? I use flakes and unstable. Sometimes app loads can be fine and then an update makes it lightning fast. I’m currently on KDE Plasma 5.27.9

A config file is always good to share to help with suggestions…

Okay, this is my config:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports = 
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      /home/andrea/src/musnix
    ];

  musnix.enable = true;

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  boot.initrd.luks.devices."luks-13b1c3db-adde-4286-bc3d-58ed68e00afd".device = "/dev/disk/by-uuid/13b1c3db-adde-4286-bc3d-58ed68e00afd";
  networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Europe/Rome";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "it_IT.UTF-8";
    LC_IDENTIFICATION = "it_IT.UTF-8";
    LC_MEASUREMENT = "it_IT.UTF-8";
    LC_MONETARY = "it_IT.UTF-8";
    LC_NAME = "it_IT.UTF-8";
    LC_NUMERIC = "it_IT.UTF-8";
    LC_PAPER = "it_IT.UTF-8";
    LC_TELEPHONE = "it_IT.UTF-8";
    LC_TIME = "it_IT.UTF-8";
  };

  # Automount Crucial
   fileSystems."/mnt/Crucial" = {
    device = "/dev/disk/by-uuid/6c8fd860-563c-443d-bc2a-e8f0c8249c44";
    fsType = "ext4";
    options = [ "defaults" ];
  };

  # Micro as default text editor
  environment.variables.EDITOR = "micro";
  environment.variables.VISUAL = "micro";

  # Firefox xinput2
  environment.sessionVariables = {
    MOZ_USE_XINPUT2 = "1";
  };

  # Make Firefox use the KDE file picker.
  # Preferences source: https://wiki.archlinux.org/title/firefox#KDE_integration
  programs.firefox = {
    enable = true;
    preferences = {
      "widget.use-xdg-desktop-portal.file-picker" = 1;
    };
  };

  # Enable OpenGL
  hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
  };

  # Load nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = ["nvidia"];

  hardware.nvidia = {

    # Modesetting is required.
    modesetting.enable = true;

    # Nvidia power management. Experimental, and can cause sleep/suspend to fail.
    powerManagement.enable = false;
    # Fine-grained power management. Turns off GPU when not in use.
    # Experimental and only works on modern Nvidia GPUs (Turing or newer).
    powerManagement.finegrained = false;

    # Use the NVidia open source kernel module (not to be confused with the
    # independent third-party "nouveau" open source driver).
    # Support is limited to the Turing and later architectures. Full list of 
    # supported GPUs is at: 
    # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus 
    # Only available from driver 515.43.04+
    # Currently alpha-quality/buggy, so false is currently the recommended setting.
    open = false;

    # Enable the Nvidia settings menu,
	# accessible via `nvidia-settings`.
    nvidiaSettings = true;

    # Optionally, you may need to select the appropriate driver version for your specific GPU.
    package = config.boot.kernelPackages.nvidiaPackages.stable;

  };

    hardware.nvidia.prime = {

    sync.enable = true;
      
  # Make sure to use the correct Bus ID values for your system!
    amdgpuBusId = "PCI:7:0:0";
    nvidiaBusId = "PCI:1:0:0";

  };

  hardware.nvidia.forceFullCompositionPipeline = true;


  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the KDE Plasma Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.displayManager.setupCommands = "/nix/store/hhw6278wghdim4sacpc7r43nwfchdvm1-xrandr-1.5.2/bin/xrandr --output eDP-1-0 --primary --mode 1920x1080 --pos 320x1440 --rotate normal --below HDMI-0 --output HDMI-0 --mode 2560x1440 --pos 0x0 --rotate normal --above eDP-1-0";
  services.xserver.desktopManager.plasma5.enable = true;

  # Configure keymap in X11
  services.xserver = {
    layout = "it";
    xkbVariant = "";
  };

  # Configure console keymap
  console.keyMap = "it2";

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.andrea = {
    isNormalUser = true;
    description = "andrea";
    extraGroups = [ "networkmanager" "wheel" "audio" ];
    packages = with pkgs; [
    #  firefox
    #  kate
    #  thunderbird
    ];
  };

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
	firefox
	kate
	thunderbird
	micro
	telegram-desktop
	signal-desktop
	mpv
	xclip
	xdg-desktop-portal
	libsForQt5.xdg-desktop-portal-kde
	reaper
	backintime
	ffmpegthumbnailer
	libsForQt5.kdegraphics-thumbnailers
	subtitleedit
	mullvad-vpn
	libsForQt5.ghostwriter
	schildichat-desktop
	krita
	ungoogled-chromium
	libsForQt5.kcalc
	audacity
	git
	freetube
	strawberry
	libreoffice-fresh
	inkscape
  #  vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
  #  wget
  ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

	services.mullvad-vpn.enable = true;
	services.cron.enable = true;
	services.jellyfin.enable = true; 
	
  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "23.05"; # Did you read the comment?

}

@Damage I’m using unstable without flakes.

what’s your CPU scheduling governor?

@Atemu as you can see I’m using musnix which, among other things, sets the governor to performance. I already tried removing it, the issues remain identical.

that indicates an I/O bottleneck to me which isn’t surprising.

How could I check that?

could also be memory/swap or GPU related

I don’t know about memory/swap, but for the gpu I followed the wiki, I don’t know if there are other steps that I’m supposed to do…

This may be zsh if you see it only when opening Konsole and you’re using zsh.

A trick is to use this line in your home-manager config to prevent it from sourcing the same file too many times:

From your config file I can see that you have a hybrid GPU system, this is the same problem I have with Intel/Nvidia but yours is AMD/Nvidia, but I am pretty sure that you have the same issue as me, the problem is on every app launching, Nvidia GPU powers on which it takes about 2–3 minutes and after a while goes to sleep, you can prevent that by specifying an env variable:

environment.variables = {
 __EGL_VENDOR_LIBRARY_FILENAMES = "/run/opengl-driver/share/glvnd/egl_vendor.d/50_mesa.json";
};

But make sure to look in /run/opengl-driver/share/glvnd/egl_vendor.d/ folder and see the available files and see if 50_mesa.json is there.

@chrism thanks, but I’m not using zsh.

@Behrad I really thought that it could have been it. But unfortunately no. I have /run/opengl-driver/share/glvnd/egl_vendor.d/50_mesa.json, but copying the env variable in my config and rebooting changes nothing unfortunately. Thank you so much anyway.

First comment out the Nvidia related settings and check if you have the same issue, if not then it should be it, it is a common problem on hybrid systems under Wayland session. If you are using plasma/Wayland, then chances are it the problem.
in that case paste the output of: echo $__EGL_VENDOR_LIBRARY_FILENAMES and ls /run/opengl-driver/share/glvnd/egl_vendor.d/
also is there any specific reason for using nvidia sync instead of offload?

Unfortunately the problem remains unchanged commenting the nvida lines. Maybe a little better, I’m not sure, but it isn’t gone so I think it isn’t (not entirely, at least?) nvidia related.

echo $__EGL_VENDOR_LIBRARY_FILENAMES returns an empty line.

ls /run/opengl-driver/share/glvnd/egl_vendor.d/ returns 10_nvidia.json and 50_mesa.json

I have chosen nvidia sync instead of offload because of this very issue: I thought that sync would have helped, keeping the GPU alive all the time. Also wiki mentions that it has better performance.
Should I use offload instead?

I’m using Xorg btw because of nvidia not working at all the last time I tried wayland.

If echo $__EGL_VENDOR_LIBRARY_FILENAMES returns nothing, then you didn’t set the env variable properly, but on the other hand you are using Xorg and AFAIK the Nvidia module loading problem doesn’t exist on Xorg.
could you repost your configuration.nix file again?
Using the offload option makes the battery life better on laptops.
I would recommend try using Plasma/Wayland on Nvidia if you have a fairly recent Nvidia GPU, which I guess you have.
I am currently on Nvidia 3060 + Plasma/Wayland, and it has been a very smooth experience.

my config is this:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports = 
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      /home/andrea/src/musnix
    ];

  musnix.enable = true;

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  boot.initrd.luks.devices."luks-13b1c3db-adde-4286-bc3d-58ed68e00afd".device = "/dev/disk/by-uuid/13b1c3db-adde-4286-bc3d-58ed68e00afd";
  networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Europe/Rome";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "it_IT.UTF-8";
    LC_IDENTIFICATION = "it_IT.UTF-8";
    LC_MEASUREMENT = "it_IT.UTF-8";
    LC_MONETARY = "it_IT.UTF-8";
    LC_NAME = "it_IT.UTF-8";
    LC_NUMERIC = "it_IT.UTF-8";
    LC_PAPER = "it_IT.UTF-8";
    LC_TELEPHONE = "it_IT.UTF-8";
    LC_TIME = "it_IT.UTF-8";
  };

  # Automount Crucial
  fileSystems."/mnt/Crucial" = {
    device = "/dev/disk/by-uuid/6c8fd860-563c-443d-bc2a-e8f0c8249c44";
    fsType = "ext4";
    options = [ "defaults" ];
  };

  # Micro as default text editor
  environment.variables.EDITOR = "micro";
  environment.variables.VISUAL = "micro";

  # Firefox xinput2
  environment.sessionVariables = {
    MOZ_USE_XINPUT2 = "1";
  };

  # Make Firefox use the KDE file picker.
  # Preferences source: https://wiki.archlinux.org/title/firefox#KDE_integration
  programs.firefox = {
    enable = true;
    preferences = {
      "widget.use-xdg-desktop-portal.file-picker" = 1;
    };
  };

  # Enable auto-optimise
  nix.settings.auto-optimise-store = true;

  # Enable OpenGL
  hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
  };

  # Load nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = ["nvidia"];

  hardware.nvidia = {

    # Modesetting is required.
    modesetting.enable = true;

    # Nvidia power management. Experimental, and can cause sleep/suspend to fail.
    powerManagement.enable = false;
    # Fine-grained power management. Turns off GPU when not in use.
    # Experimental and only works on modern Nvidia GPUs (Turing or newer).
    powerManagement.finegrained = false;

    # Use the NVidia open source kernel module (not to be confused with the
    # independent third-party "nouveau" open source driver).
    # Support is limited to the Turing and later architectures. Full list of 
    # supported GPUs is at: 
    # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus 
    # Only available from driver 515.43.04+
    # Currently alpha-quality/buggy, so false is currently the recommended setting.
    open = false;

    # Enable the Nvidia settings menu,
	# accessible via `nvidia-settings`.
    nvidiaSettings = true;

    # Optionally, you may need to select the appropriate driver version for your specific GPU.
    package = config.boot.kernelPackages.nvidiaPackages.stable;

  };

    hardware.nvidia.prime = {

    sync.enable = true;
      
  # Make sure to use the correct Bus ID values for your system!
    amdgpuBusId = "PCI:7:0:0";
    nvidiaBusId = "PCI:1:0:0";

  };

  hardware.nvidia.forceFullCompositionPipeline = true;

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the KDE Plasma Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.displayManager.setupCommands = "/nix/store/hhw6278wghdim4sacpc7r43nwfchdvm1-xrandr-1.5.2/bin/xrandr --output eDP-1-0 --primary --mode 1920x1080 --pos 320x1440 --rotate normal --below HDMI-0 --output HDMI-0 --mode 2560x1440 --pos 0x0 --rotate normal --above eDP-1-0";
  services.xserver.desktopManager.plasma5.enable = true;

  # Configure keymap in X11
  services.xserver = {
    layout = "it";
    xkbVariant = "";
  };

  # Configure console keymap
  console.keyMap = "it2";

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.andrea = {
    isNormalUser = true;
    description = "andrea";
    extraGroups = [ "networkmanager" "wheel" "audio" ];
    packages = with pkgs; [
    #  firefox
    #  kate
    #  thunderbird
    ];
  };

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
	firefox
	kate
	thunderbird
	micro
	telegram-desktop
	signal-desktop
	mpv
	xclip
	reaper
	backintime
	ffmpegthumbnailer
	libsForQt5.kdegraphics-thumbnailers
	subtitleedit
	mullvad-vpn
	libsForQt5.ghostwriter
	schildichat-desktop
	krita
	ungoogled-chromium
	libsForQt5.kcalc
	audacity
	git
	freetube
	strawberry
	libreoffice-fresh
	inkscape
	nicotine-plus
  #  vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
  #  wget
  ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

	services.mullvad-vpn.enable = true;
	services.cron.enable = true;
	services.jellyfin.enable = true;
	
  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "23.05"; # Did you read the comment?

}

To enable wayland I just have to select it from sddm or I have to change something in my configuration.nix? I’ll try it again.

I’ll try to switch to offload instead of sync too, but I don’t think it will change the issue, IIRC I did already try it.

So I switch to wayland and try again with your env variable? I have no idea why I haven’t any, I just followed the wiki…

For switching to Wayland that would be sufficient to just select Wayland session from sddm, but some applications may start in xwayland such as Firefox or electron apps, but solving that is not the priority right now.
I can’t find the env variable in your config file, make sure to include environment.variables.__EGL_VENDOR_LIBRARY_FILENAMES = "/run/opengl-driver/share/glvnd/egl_vendor.d/50_mesa.json";
in your config file and run nixos-rebuild boot and reboot your system.

Sorry, my bad.
This is my config now:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports = 
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      /home/andrea/src/musnix
    ];

  musnix.enable = true;

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  boot.initrd.luks.devices."luks-13b1c3db-adde-4286-bc3d-58ed68e00afd".device = "/dev/disk/by-uuid/13b1c3db-adde-4286-bc3d-58ed68e00afd";
  networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Europe/Rome";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "it_IT.UTF-8";
    LC_IDENTIFICATION = "it_IT.UTF-8";
    LC_MEASUREMENT = "it_IT.UTF-8";
    LC_MONETARY = "it_IT.UTF-8";
    LC_NAME = "it_IT.UTF-8";
    LC_NUMERIC = "it_IT.UTF-8";
    LC_PAPER = "it_IT.UTF-8";
    LC_TELEPHONE = "it_IT.UTF-8";
    LC_TIME = "it_IT.UTF-8";
  };

  # Automount Crucial
  fileSystems."/mnt/Crucial" = {
    device = "/dev/disk/by-uuid/6c8fd860-563c-443d-bc2a-e8f0c8249c44";
    fsType = "ext4";
    options = [ "defaults" ];
  };

  # Default text editor
  programs.vim.defaultEditor = true;

  # Fix GTK themes in Wayland
  programs.dconf.enable = true;

  # Keep GPU alive
  environment.variables.__EGL_VENDOR_LIBRARY_FILENAMES = "/run/opengl-driver/share/glvnd/egl_vendor.d/50_mesa.json";

  # Firefox xinput2
  environment.sessionVariables = {
    MOZ_USE_XINPUT2 = "1";
  };

  # Make Firefox use the KDE file picker.
  # Preferences source: https://wiki.archlinux.org/title/firefox#KDE_integration
  programs.firefox = {
    enable = true;
    preferences = {
      "widget.use-xdg-desktop-portal.file-picker" = 1;
    };
  };

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

  # Enable auto-optimise
  nix.settings.auto-optimise-store = true;

  # Enable OpenGL
  hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
  };

  # Load nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = ["nvidia"];

  hardware.nvidia = {

    # Modesetting is required.
    modesetting.enable = true;

    # Nvidia power management. Experimental, and can cause sleep/suspend to fail.
    powerManagement.enable = false;
    # Fine-grained power management. Turns off GPU when not in use.
    # Experimental and only works on modern Nvidia GPUs (Turing or newer).
    powerManagement.finegrained = false;

    # Use the NVidia open source kernel module (not to be confused with the
    # independent third-party "nouveau" open source driver).
    # Support is limited to the Turing and later architectures. Full list of 
    # supported GPUs is at: 
    # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus 
    # Only available from driver 515.43.04+
    # Currently alpha-quality/buggy, so false is currently the recommended setting.
    open = false;

    # Enable the Nvidia settings menu,
	# accessible via `nvidia-settings`.
    nvidiaSettings = true;

    # Optionally, you may need to select the appropriate driver version for your specific GPU.
    package = config.boot.kernelPackages.nvidiaPackages.stable;

  };

    hardware.nvidia.prime = {

    sync.enable = true;
      
  # Make sure to use the correct Bus ID values for your system!
    amdgpuBusId = "PCI:7:0:0";
    nvidiaBusId = "PCI:1:0:0";

  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the KDE Plasma Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.displayManager.setupCommands = "/nix/store/hhw6278wghdim4sacpc7r43nwfchdvm1-xrandr-1.5.2/bin/xrandr --output eDP-1-0 --primary --mode 1920x1080 --pos 320x1440 --rotate normal --output HDMI-0 --mode 2560x1440 --pos 0x0 --rotate normal";
  services.xserver.desktopManager.plasma5.enable = true;

  # Configure keymap in X11
  services.xserver = {
    layout = "it";
    xkbVariant = "";
  };

  # Configure console keymap
  console.keyMap = "it2";

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.andrea = {
    isNormalUser = true;
    description = "andrea";
    extraGroups = [ "networkmanager" "wheel" "audio" ];
    packages = with pkgs; [
    #  firefox
    #  kate
    #  thunderbird
    ];
  };

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
	firefox
	kate
	thunderbird
	telegram-desktop
	signal-desktop
	mpv
	reaper
	backintime
	ffmpegthumbnailer
	libsForQt5.kdegraphics-thumbnailers
	subtitleedit
	mullvad-vpn
	libsForQt5.ghostwriter
	schildichat-desktop
	krita
	ungoogled-chromium
	libsForQt5.kcalc
	audacity
	git
	freetube
	strawberry
	libreoffice-fresh
	inkscape
	nicotine-plus
  #  vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
  #  wget
  ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

	services.mullvad-vpn.enable = true;
	services.cron.enable = true;
	services.jellyfin.enable = true;
	
  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "23.05"; # Did you read the comment?

}

On wayland I have issues with firefox and electron apps as you said, but it seems that dolphin in started faster.
To be honest, it’s not instant. I tried with a live of nixos to check if the issue could be in my config, and in the live is as fast as it is now on wayland. It takes like a second, which is not much, but still noticeably slower than it is in any other distro. I don’t know if this information is useful. Does it opens instantly for you?
Anyway, now echo $__EGL_VENDOR_LIBRARY_FILENAMES returns /run/opengl-driver/share/glvnd/egl_vendor.d/50_mesa.json.

Is there anything in my cnfigs that may assist. Mine ran good and smooth but there was noticeable glitches under wayland but my session of Dolphin ooend up rather fastvunder both wayland and x11 although i had network shares automounted.

https://github.com/tolgaerok/nixos-kde/blob/61155c6b23133109889b1a3f81a11374465ed93c/core/gpu/nvidia/nvidia-stable-opengl/default.nix

For forcing Firefox and electron apps to use Wayland, set these variables:

environment.sessionVariables.NIXOS_OZONE_WL = "1";
environment.sessionVariables.MOZ_ENABLE_WAYLAND = "1";

I can confirm it can be a little slower sometimes, but most of the time I’m not noticed it.
If you are using pipewire you can remove sound.enable = true;
also, it is a good practice to install Firefox by this option and remove it from environment.systemPackages:

    programs.firefox = {
      enable = true;
      package = pkgs.firefox-wayland;
    };

At the end keep your system up-to-date, the recent KDE Plasma 5.27.9 has been much better if you are not on it.

1 Like

https://github.com/tolgaerok/nixos-kde/blob/61155c6b23133109889b1a3f81a11374465ed93c/core/gpu/intel/intel-laptop-hybrid-nvidia/offload-prime.nix

Interesting… why? I have both and have no issues unless im missing something here .

As it says in this unofficial wiki page,

Remove sound.enable or set it to false if you had it set previously, as sound.enable is only meant for ALSA-based configurations

Thank you very much both @Behrad and @tolgaerok, I tried everything, I looked at the github repos linked, tried with many configs, tried with the suggestions, but nothing works. It just seems like nixos don’t like my pc, which is weird, but I don’t know what to try anymore, I guess I’ll just live with it. Thank you anyway for the help.

1 Like

Comment out set commends in display manager xserver xrander and rebuild. And set it manually in the plasma display and see what happens