[nvidia] Attempts to fix flicker

Switch to nouveau
This commit is contained in:
Tibo De Peuter 2024-03-04 16:54:28 +01:00
parent e810827331
commit 15e00efe3e
4 changed files with 50 additions and 11 deletions

View file

@ -45,6 +45,7 @@
"spotify" "spotify"
"steam" "steam-original" "steam-run" "steam" "steam-original" "steam-run"
"vista-fonts" "vista-fonts"
"nvidia-persistenced" # Docker
]; ];
in in
utils.lib.mkFlake { utils.lib.mkFlake {

View file

@ -6,6 +6,8 @@
]; ];
sisyphus = { sisyphus = {
desktop.sway.enable = true;
hardware.nvidia = { hardware.nvidia = {
enable = true; enable = true;
model = "Quadro T2000"; model = "Quadro T2000";

View file

@ -38,6 +38,26 @@ let
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface gnome_schema=org.gnome.desktop.interface
# gsettings set $gnome_schema gtk-theme 'Dracula' # gsettings set $gnome_schema gtk-theme 'Dracula'
# https://github.com/crispyricepc/sway-nvidia/blob/2101a18698151a61266740f1297158119bf660ac/wlroots-env-nvidia.sh
# Hardware cursors not yet working on wlroots
export WLR_NO_HARDWARE_CURSORS=1
# Set wlroots renderer to Vulkan to avoid flickering
export WLR_RENDERER=vulkan
# General wayland environment variables
export XDG_SESSION_TYPE=wayland
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
# Firefox wayland environment variable
export MOZ_ENABLE_WAYLAND=1
export MOZ_USE_XINPUT2=1
# OpenGL Variables
export GBM_BACKEND=nvidia-drm
export __GL_GSYNC_ALLOWED=0
export __GL_VRR_ALLOWED=0
export __GLX_VENDOR_LIBRARY_NAME=nvidia
# Xwayland compatibility
export XWAYLAND_NO_GLAMOR=1
''; '';
}; };
in { in {
@ -100,14 +120,17 @@ in {
power-profiles-daemon.enable = true; power-profiles-daemon.enable = true;
xserver.displayManager.session = [{ xserver = {
manage = "window"; displayManager.session = [{
name = "Sway"; manage = "window";
start = '' name = "Sway";
${pkgs.sway}/bin/sway --unsupported-gpu & start = ''
waitPID=$! ${pkgs.sway}/bin/sway --unsupported-gpu &
''; waitPID=$!
}]; '';
}];
videoDrivers = [ "nouveau" ];
};
}; };
xdg.portal = { xdg.portal = {

View file

@ -3,6 +3,7 @@
let let
cfg = config.sisyphus.hardware.nvidia; cfg = config.sisyphus.hardware.nvidia;
# The graphics cards for which to do offloading
do-offloading = builtins.elem cfg.model [ "Quadro T2000" ]; do-offloading = builtins.elem cfg.model [ "Quadro T2000" ];
nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" '' nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
export __NV_PRIME_RENDER_OFFLOAD=1 export __NV_PRIME_RENDER_OFFLOAD=1
@ -24,8 +25,17 @@ in {
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.xserver.videoDrivers = [ "nvidia" ]; # boot = {
# extraModprobeConfig = "options nvidia-drm modeset=1";
#
# initrd.kernelModules = [
# "nvidia"
# "nvidia_modeset"
# "nvidia_uvm"
# "nvidia_drm"
# ];
# };
hardware = { hardware = {
opengl = { opengl = {
enable = true; enable = true;
@ -33,7 +43,7 @@ in {
driSupport32Bit = true; driSupport32Bit = true;
}; };
nvidia = { nvidia = {
open = true; open = false;
package = config.boot.kernelPackages.nvidiaPackages.stable; package = config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.enable = true; modesetting.enable = true;
nvidiaSettings = cfg.gui-settings; nvidiaSettings = cfg.gui-settings;
@ -42,6 +52,9 @@ in {
finegrained = do-offloading; finegrained = do-offloading;
}; };
# Avoid flickering
forceFullCompositionPipeline = true;
prime = lib.mkMerge [ prime = lib.mkMerge [
(lib.mkIf do-offloading { (lib.mkIf do-offloading {
offload = { offload = {