Waking from sleep completely breaks KDE Desktop

This did not happen on Tumbleweed, so there MUST be a way to fix this, surely. I just need help from you good people who know more than I do. I have a 4090 running the 565.77 proprietary NVIDIA drivers.

This happens when waking from hibernate too, in order to go back to normal I have to logout and login again then its fine. I added this to my config file:

boot.kernelParams = [
“nvidia.NVreg_EnableGpuShutdown=1”
“nvidia.NVreg_PreserveVideoMemoryAllocations=1”
“mem_sleep_default=deep”
“nvidia.NVreg_RegistryDwords=EnableProcfsSuspend=1”

But when I do this, the system does not sleep at all, I tell it to sleep and then it just ends up on the lock screen. This issue persists even if I remove all of the other stuff and keep "nvidia.NVreg_PreserveVideoMemoryAllocations=1". If I remove this line, the original issue of my desktop breaking comes back.

My driver setup in the config file:

services.xserver.videoDrivers = [“nvidia”];
hardware.nvidia.modesetting.enable = true;
hardware.nvidia.open = false;

Found the solution, simpy add this to the configuration.nix file.

hardware.nvidia.powerManagement.enable = true;