No sound after installing Nvidia driver

Im trying to install nvidia graphic driver and when I reboot, xfce desktop just break with invisible menu and it is impossible to use brower since is is very slow. I did some research and it is an existing problem on other distros but I don’t know how to resolve it on NixOS.
Here is my configuration:

{ config, pkgs,  lib, ... }:
{
	#enable Nvidia driver
	hardware.graphics.enable = true;
	services.xserver.videoDrivers = ["nvidia" "intel" "modesetting"];
	
	hardware.nvidia.open = false;
	hardware.nvidia.prime = {
		#Enable sync mode
		sync.enable = true;
	
    		intelBusId = "PCI:0@0:2:0";
    		nvidiaBusId = "PCI:1@0:0:0";
  	};
  	
  	#Modesetting is required
	hardware.nvidia.modesetting.enable = true;
	#Enable Nvidia settings menu,
	#accessible via `nvidia-setting`.
	hardware.nvidia.nvidiaSettings = true;
	
  	#Disable kernel module
  	#boot.kernelParams = [ "module_blacklist=i915" ];
  	#Add boot module
  	boot.extraModulePackages = [ 
  		config.boot.kernelPackages.nvidia_x11
  		config.boot.kernelPackages.lenovo-legion-module
  	];
  	hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
# 	hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
#		    version = "580.105.08";
#		    sha256_64bit = "sha256-2cboGIZy8+t03QTPpp3VhHn6HQFiyMKMjRdiV2MpNHU=";
#		    sha256_aarch64 = "sha256-2cboGIZy8+t03QTPpp3VhHn6HQFiyMKMjRdiV2MpNHU=";
#		    openSha256 = "sha256-YvzWO1U3am4Nt5cQ+b5IJ23yeWx5ud1HCu1U0KoojLY=";
#		    settingsSha256 = "sha256-YvzWO1U3am4Nt5cQ+b5IJ23yeWx5ud1HCu1U0KoojLY=";
#		    persistencedSha256 = lib.fakeSha256;
#  	};
}

my graphic card is rtx4050 laptop.
turned out it was a picom problem, I turned it off and now it works fine. The new problem is the driver is not recognising my second monitor and there is no audio.

Here is my dmesg | grep -C 5 audio output:

[    4.996938] intel_tcc_cooling: Programmable TCC Offset detected
[    4.998225] intel_rapl_common: Found RAPL domain package
[    5.006700] snd_hda_intel 0000:00:1f.3: enabling device (0000 -> 0002)
[    5.007356] snd_hda_intel 0000:01:00.1: enabling device (0000 -> 0002)
[    5.007424] snd_hda_intel 0000:01:00.1: Disabling MSI
[    5.007430] snd_hda_intel 0000:01:00.1: Handle vga_switcheroo audio client
[    5.042690] input: FTCS0038:00 2808:0106 Mouse as /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-0/i2c-FTCS0038:00/0018:2808:0106.000B/input/input23
[    5.044017] mc: Linux media interface: v0.10
[    5.044901] input: FTCS0038:00 2808:0106 Touchpad as /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-0/i2c-FTCS0038:00/0018:2808:0106.000B/input/input24
[    5.048155] mousedev: PS/2 mouse device common for all mice
[    5.052852] hid-multitouch 0018:2808:0106.000B: input,hidraw10: I2C HID v1.00 Mouse [FTCS0038:00 2808:0106] on i2c-FTCS0038:00
--
[   15.011059] nvme nvme0: using unchecked data buffer
[   15.034275] block nvme0n1: No UUID available providing old NGUID
[   15.168090] Bluetooth: RFCOMM TTY layer initialized
[   15.168099] Bluetooth: RFCOMM socket layer initialized
[   15.168102] Bluetooth: RFCOMM ver 1.11
[   15.939951] pci 0000:00:1f.3: deferred probe pending: snd_hda_intel: couldn't bind with audio component

I have tried everything I could, all the existing no sound help for nixos are having completely different output from me and they use the old audio.enable setting.

I fixed it, thanks to nixos-hardware/lenovo/legion/16irx9h/default.nix at 4ed851c979641e28597a05086332d75cdc9e395f · NixOS/nixos-hardware · GitHub. I added this line:

 # Sound speaker fix, see #1039
  boot.extraModprobeConfig = ''
    options snd-hda-intel model=auto
  '';