Hyprland Nvidia flickering

Hello guys, I’m fairly new to Nix and Linux generally and falling in love with it. however I have a small inconvenient. I have set my configuration all according to manual and I have done everything I could possibly find.

I have a Razer 15 laptop. Using hyprland from the flake nvidia seems working even though nothing shows in nvidia-settings but checking nvidia-smi looks like its working.

My problem is when I attach my laptop to TV with an HDMI the TV monitor flickers its very annoying I cant enjoy whatever I’m watching. However when using services.xserver.videoDrivers = [ "modesetting" ]; using my intel GPU instead of nvidia and attach my laptop there is no problems. I would like to have my nvidia running instead of rebuilding everytime I need it. which is what I’m doing right now

here is my nvidia module for reference
its a mess because I have pasted everything I thought that could fix it

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

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


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

    config = ''
      Section "Device"
          Identifier  "Intel Graphics"
          Driver      "intel"
          #Option      "AccelMethod"  "sna" # default
          #Option      "AccelMethod"  "uxa" # fallback
          Option      "TearFree"        "true"
          Option      "SwapbuffersWait" "true"
          BusID       "PCI:0:2:0"
          #Option      "DRI" "2"             # DRI3 is now default
      EndSection

      Section "Device"
          Identifier "nvidia"
          Driver "nvidia"
          BusID "PCI:1:0:0"
          Option "AllowEmptyInitialConfiguration"
      EndSection
    '';
    screenSection = ''
      Option         "metamodes" "nvidia-auto-select +0+0 {ForceFullCompositionPipeline=On}"
      Option         "AllowIndirectGLXProtocol" "off"
      Option         "TripleBuffer" "on"
    '';
  };

  hardware.opengl.enable = true;
  hardware.opengl.driSupport = true;
  hardware.opengl.driSupport32Bit = true;
  hardware.nvidia.nvidiaSettings = true;
  hardware.nvidia.powerManagement.enable = true;
  hardware.nvidia.forceFullCompositionPipeline = true;

  # Cuda
  services.xmr-stak.cudaSupport = true; 
  # Optionally, you may need to select the appropriate driver version for your specific GPU.
  hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
  # nvidia-drm.modeset=1 is required for some wayland compositors, e.g. sway
  hardware.nvidia.modesetting.enable = true;
}

and here is my home.nix variables

    home.sessionVariables = {
	    BROWSER = "google-chrome-beta";
	    TERMINAL = "kitty";
	    NIXOS_OZONE_WL = "1";
	    QT_QPA_PLATFORMTHEME = "gtk3";
	    QT_SCALE_FACTOR = "1";
	    #MOZ_ENABLE_WAYLAND = "1";
	    SDL_VIDEODRIVER = "wayland";
	    _JAVA_AWT_WM_NONREPARENTING = "1";
	    QT_QPA_PLATFORM = "wayland-egl";
	    QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
	    QT_AUTO_SCREEN_SCALE_FACTOR = "1";
	    WLR_DRM_DEVICES = "/dev/dri/card1:/dev/dri/card0";
	    WLR_NO_HARDWARE_CURSORS = "1"; # if no cursor,uncomment this line  
	    # GBM_BACKEND = "nvidia-drm";
	    CLUTTER_BACKEND = "wayland";
	    __GLX_VENDOR_LIBRARY_NAME = "nvidia";
	    LIBVA_DRIVER_NAME = "nvidia";
	    WLR_RENDERER = "vulkan";
	    __NV_PRIME_RENDER_OFFLOAD="1";
	    XDG_CURRENT_DESKTOP = "Hyprland";
	    XDG_SESSION_DESKTOP = "Hyprland";
	    XDG_SESSION_TYPE = "wayland";
	    GTK_USE_PORTAL = "1";
	    NIXOS_XDG_OPEN_USE_PORTAL = "1";
	    XDG_CACHE_HOME = "\${HOME}/.cache";
	    XDG_CONFIG_HOME = "\${HOME}/.config";
	    XDG_BIN_HOME = "\${HOME}/.local/bin";
	    XDG_DATA_HOME = "\${HOME}/.local/share";
    };

There is one ‘nuclear’ fix in hyprland wiki but it makes my laptop so hot and noisy.
which is forcing nvidia to work over time, its to add:

options nvidia NVreg_RegistryDwords="PowerMizerEnable=0x1; PerfLevelSrc=0x2222; PowerMizerLevel=0x3; PowerMizerDefault=0x3; PowerMizerDefaultAC=0x3"

in /etc/modprobe.d/nvidia.conf

“Do note though that this forces performance mode to be active, resulting in increased power-consumption (from 22W idle on a RTX 3070TI, to 74W).”

Lastly, I do have nvidia patch applied in my flake.nix here

{
  description = "Hyprland+waybar";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    hyprland.url = "github:hyprwm/Hyprland";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";   };


  outputs = { self, nixpkgs, hyprland, home-manager, ... }: 
    let
      user = "nomad";
      system = "x86_64-linux";
      pkgs = import nixpkgs {
       inherit system;
       config.allowUnfree = true;
        };
      lib = nixpkgs.lib;
    in {
      nixosConfigurations = {
        ${user} = nixpkgs.lib.nixosSystem {
          inherit system;
          specialArgs = {inherit user;};
          modules = [ ./configuration.nix 
              
            hyprland.nixosModules.default
            {
              programs.hyprland.enable = true;
              programs.hyprland.nvidiaPatches=true;
              programs.hyprland.xwayland.enable=true;
            }
            home-manager.nixosModules.home-manager
            {
              home-manager.useGlobalPkgs = true;
              home-manager.useUserPackages = true;
              home-manager.extraSpecialArgs = {inherit user;};
              home-manager.users.${user} = import ./modules/home.nix;

if you have the time and want to look through my whole setup here is the repo

Thanks in advance!

Nvidia fixed “flickering” in the latest driver, but who knows whether that fixes your particular problem: Linux x64 (AMD64/EM64T) Display Driver | 535.98 | Linux 64-bit | NVIDIA