Hyprland + nvidia 4060 = flickering in some apps

I’m relatively new to nixos and hyprland.
So, issue I’m having is flickering in some electron apps (I guess). Namely chrome based brousers and Onlyoffice client.
I have read and tried different solutions nvidia and flickering related but i still having this issue no matter what, so here I am, asking for help…

Hyprland related code:

            programs.hyprland.enable = true;

            xdg.portal.enable = true;
            xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
            programs.hyprland = {
                xwayland.enable = true;
            };

            environment = {
                sessionVariables = {
                    NIXOS_OZONE_WL = "1"; # Hint electron apps to use wayland
                    WLR_NO_HARDWARE_CURSORS = "1"; # Fix cursor rendering issue on wlr nvidia.

                    XDG_CURRENT_DESKTOP = "Hyprland";
                    XDG_SESSION_TYPE = "wayland";
                    XDG_SESSION_DESKTOP = "Hyprland";

                    GBM_BACKEND = "nvidia-drm";
                    __GLX_VENDOR_LIBRARY_NAME = "nvidia";
                    LIBVA_DRIVER_NAME = "nvidia";
                    __GL_GSYNC_ALLOWED = "1";
                    __GL_VRR_ALLOWED = "0"; 
                    WLR_DRM_NO_ATOMIC = "1";

                    QT_AUTO_SCREEN_SCALE_FACTOR = "1";
                    QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
                    QT_QPA_PLATFORM = "wayland";
                    QT_QPA_PLATFORMTHEME = "qt5ct";

                    GDK_SCALE = "2";

                    ELECTRON_OZONE_PLATFORM_HINT = "auto";

                    NVD_BACKEND = "direct";
                };

                systemPackages = with pkgs; [
                    pyprland
                ];
            };

Nvidia related code:

        services.xserver = {
            enable = true;
            videoDrivers = [ "nvidia" ]; 
        };

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


        hardware.nvidia = {
            modesetting.enable = true;

            powerManagement.enable = false;

            powerManagement.finegrained = false;

            open = true;

            nvidiaSettings = true;

            package = config.boot.kernelPackages.nvidiaPackages.stable;
        };

Any suggestions are appreciated, thank you :slight_smile:

From what I understand, Hyprland uses Wayland for rendering.
With nvidia chips, explicit sync is necessary to get flicker-free output.
You’re probably on the nvidia 550.x.y driver (using the stable nvidia driver suggests as much) which doesn’t have explicit sync yet. The 555.x.y driver is currently in beta though.

Your options are:

  1. To wait until the 555.x.y driver becomes stable, at which point this issue should resolve itself. In the meantime perhaps use a different DE or WM.

  2. Install the 555.x.y beta driver. Doing this will require you to know how to work with flakes, in order to properly update the nvidia driver entry in your configuration.nix.

2 Likes

Thank you! I will try solution with flakes.
Is 555 drivers are so beta, that they are newer than drivers in config.boot.kernelPackages.nvidiaPackages.beta ?

Think of it this way: the beta in the link I gave you is more of a specific snapshot of that beta driver, hence the hashes.

Which beta version the config.boot.kernelPackages.nvidiaPackages.beta option installs is dependent on the maintainer of that nix code.
It might be worth a shot to try the beta option before trying the snapshot. If that works, it’s an easier solution.

1 Like

I’ve tried

hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
                version = "555.42.02";
                sha256_64bit = "sha256-k7cI3ZDlKp4mT46jMkLaIrc2YUx1lh1wj/J4SVSHWyk=";
                sha256_aarch64 = lib.fakeSha256;
                openSha256 = "sha256-3/eI1VsBzuZ3Y6RZmt3Q5HrzI2saPTqUNs6zPh5zy6w=";
                settingsSha256 = "sha256-rtDxQjClJ+gyrCLvdZlT56YyHQ4sbaL+d5tL4L4VfkA=";
                persistencedSha256 = lib.fakeSha256;

            };

But flickering still in place :cry:

Edit:
Should I change lib.fakeSha256 to something else? (Nix doesn’t complain about it)

No that wouldn’t help. But the beta driver not helping points to a deeper issue.
As it turns out, here is the real culprit.

1 Like

Thank you, I will explore it :slight_smile:

Edit:
I switched to nix-unstable with nvidia 555.52.04, but flickering remains.
I will wait till someone writes explicit sync protocol, I guess…
Thanks anyway :slight_smile:

Remove all session env vars but the absolutely necessary ones for anything to function; one of those could be causing this issue.

A lot of the env vars you have set do not make sense to set globally. Don’t set env vars unless you know exactly what they actually do and who should set them.

1 Like

I switched to unstable branch and flickering is gone. But hyprland started to detect 2 monitors instead of 1 and there are some other annoying issues, so i’m switching back :slight_smile:

1 Like

I switched to 24.05 and all issues are gone.


Thanks for help, you all :wink:

1 Like

Update:
there are some flickering in apps still, but from some apps this issue is gone. OnlyOffice, for example, behaves normal. But on some other apps, Minecraft, for example, flickering is still there and it is very annoying.
Now I’m using i3… less fancy staff, but it works :slight_smile:

I wonder if it’s because you’re using the hardware.nvidia.open = true; module (if you’re still using it) as it might not be stable enough in NixOS 24.05 (if you’re still on 24.05).

1 Like

It may be, I will try setting it to false, thank you :slight_smile:

1 Like

Sadly, switching this option to false didn’t solve any new issues for me on wayland.

1 Like