Skip to content

Instantly share code, notes, and snippets.

@iliketwertles
Created August 29, 2022 22:56
Show Gist options
  • Save iliketwertles/137cdec6d930fe0223800ee2448f984c to your computer and use it in GitHub Desktop.
Save iliketwertles/137cdec6d930fe0223800ee2448f984c to your computer and use it in GitHub Desktop.
nvidia+hyprland/wayland guide

First of all this is no where near a cure-all or universal guide, this is just my experience with my specific card and system. This is what has gotten my MSI 1650 Super Gaming X gpu (probably overly specific lol) to work on hyprland, not sure if this works on any other wayland compositors but i assume it would work for sway, newm, etc

Anyways lets start with a basic arch install with the regular kernel and some basic packages including but not limited to: dkms, base-devel, git, yay, etc

Next is to get nvidia stuff figured out, if your card is supported, use nvidia-open-dkms, if not, nvidia-dkms. Then ensure nvidia modules are in the MODULES= section of mkinitcpio like this (MODULES="nvidia nvidia_drm nvidia_modeset nvidia_uvm") then running: "mkinitcpio -P". I suggest making a packman hook to rebuild initramfs whenever either 'linux' (kernel) or nvidia-open-dkms (driver) is updated. That would look like this:

[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=nvidia-open-dkms
Target=linux

[Action]
Description=sugma
Depends=mkinitcpio
When=PostTransaction
NeedsTargets
Exec=/bin/sh -c 'while read -r trg; do case $trg in linux) exit 0; esac; done; /usr/bin/mkinitcpio -P'

Last step for nvidia is setting some stuff in your bootloader, adding nvidia_drm.modeset=1 to "options" in systemd-boot should work in that case, for grub it will be similer

And of course, rebooting when needed. Assuming everything is done correctly and it is going to work, the next steps should be related to what wm/compositor you would like to use, this guide goes over hyprland

As recommended, we are going to be wrapping the hyprland launcher as such:

#!/bin/sh

cd ~

export _JAVA_AWT_WM_NOREPARENTING=1
export XCURSOR_SIZE=24
export LIBVA_DRIVER_NAME=nvidia
export CLUTTER_BACKEND=wayland
export XDG_SESSION_TYPE=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
export MOZ_ENABLE_WAYLAND=1
export GBM_BACKEND=nvidia-drm
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export WLR_NO_HARDWARE_CURSORS=1
export WLR_BACKEND=vulkan
export QT_QPA_PLATFORM=wayland
export GDK_BACKEND=wayland


exec Hyprland

Saving this file as "wrappedhl" somewhere in PATH, hyprland wiki suggests .local however ive had better luck with sddm when its in /usr/local/bin however as long as its in PATH it doesnt make much of a difference.

Next step is editing the .desktop file in /usr/share/wayland-sessions/hyprland.desktop simply replacing Exec=Hyprland to 'Exec=wrappedhl' (you might need to put the full path of the script if this doesnt launch)

Additionally install these packages qt5-wayland, qt5ct, libva, nvidia-vaapi-driver-git(AUR) to fix some electron apps. Along with all that I recommend rebooting one more time to insure all drivers are loaded, and if its gonna work at all, it will work now. However if you experience flickering artifacts from being idle for ~5 seconds, you will need to do some extra work.

This does force performance mode to be on perminatly, increasing power usage by quite a bit. To do this... Create a file /etc/modprobe.d/nvidia.conf with the this being in the file:

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

After rebooting it should stop

Thats about it for this, most of the info in this gist can be found on the nvidia portion of the hyprland wiki at https://wiki.hyprland.org/Nvidia/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment