NixOS + Wayland + Plasma + Nvidia causes black screen on login with only mouse visible

Hello all. New NixOS user, long time Linux enjoyer here.

I am trying to create a setup to migrate all of my machines over to NixOS, and some of them have RTX Nvidia cards on them, so I created an nvidia-rtx.nix file and set it to import to my main configuration.nix.

Here is my nvidia-rtx.nix

{ config, lib, pkgs, ... }:

{

  options = {
    # Define any custom options here if needed.
  };

  config = {
    boot.kernelParams = [ "nvidia-drm.modeset=1" ];

    hardware.opengl = {
      enable = true;
      driSupport = true;
      driSupport32Bit = true;
    };

    services.xserver.videoDrivers = [ "nvidia" ];

    hardware.nvidia = {
#      forceFullCompositionPipeline = true;
      modesetting.enable = true;
      powerManagement.enable = false;
      powerManagement.finegrained = false;
      open = false;
      nvidiaSettings = true;
      package = config.boot.kernelPackages.nvidiaPackages.stable;
    };
  };
}
# Remove the line about forcefullcompositionpipeline if you get bad OpenGL and WebGL performance

I also have some X11 things that came with my configuration.nix

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

  # Enable the KDE Plasma Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.desktopManager.plasma5.enable = true;

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

I seem to have an issue in which X11 works aside from performance issues from having a 1080p and 4K display at different refresh rates - but when I try to enter Plasma via Wayland, I get a black screen in which only my mouse is visible. To fix it, I have to force a reboot by holding the power button and then switch back into X11 at the login screen. Any ideas?

Additionally, I have tried different power saving settings in that nvidia-rtx.nix file, and disabling i915 with a boot kernel param

I have been told in other places that it could be due to SDDM or Plasma configs, but my config is bone stock with no changes made

Also I can boot into SDDM with Wayland using this

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

  # Enable the KDE Plasma Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.desktopManager.plasma5.enable = true;
  
  # Use Wayland in Plasma and SDDM
  services.xserver.displayManager.defaultSession = "plasma";
  services.xserver.displayManager.sddm.wayland.enable = true;

but when I sign in with my user account is when I get the black screen with just a cursor

Well it appears that despite me making no config changes, something in Plasma caused issues relating to Wayland on my home folder

I created a new user and that user had perfect Wayland + NixOS + Nvidia + Plasma KDE

So I nuked my KDE config for my current user and it worked. I it runs perfectly now.

I used ChatGPT to create a small script to nuke my KDE install to fix this.

Here’s a link to the config nuker that fixed this for me