From 42570b6d001759e14bc0988e4dc53be19a103d4c Mon Sep 17 00:00:00 2001 From: ooks-io Date: Fri, 9 Aug 2024 21:50:31 +1200 Subject: [PATCH] fix(nixos:hardware) hardware.opengl -> hardware.graphics --- nixos/modules/gaming/gamescope.nix | 2 +- .../modules/host/hardware/features/video.nix | 4 +-- nixos/modules/host/hardware/gpu/amd.nix | 2 +- nixos/modules/host/hardware/gpu/intel.nix | 4 +-- nixos/modules/host/hardware/gpu/nvidia.nix | 27 ++++++++++++++----- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/nixos/modules/gaming/gamescope.nix b/nixos/modules/gaming/gamescope.nix index f715154..3c92d17 100644 --- a/nixos/modules/gaming/gamescope.nix +++ b/nixos/modules/gaming/gamescope.nix @@ -8,7 +8,7 @@ cfg = config.ooknet.gaming.gamescope; in { config = mkIf cfg.enable { - hardware.opengl.extraPackages = [pkgs.gamescope]; + hardware.graphics.extraPackages = [pkgs.gamescope]; programs.gamescope = { enable = true; capSysNice = true; diff --git a/nixos/modules/host/hardware/features/video.nix b/nixos/modules/host/hardware/features/video.nix index a79d73e..685171d 100644 --- a/nixos/modules/host/hardware/features/video.nix +++ b/nixos/modules/host/hardware/features/video.nix @@ -12,9 +12,9 @@ in { config = mkIf (elem "video" features) { hardware = { - opengl = { + graphics = { enable = true; - driSupport32Bit = isx86Linux pkgs; + enable32Bit = isx86Linux pkgs; }; }; xdg.portal = { diff --git a/nixos/modules/host/hardware/gpu/amd.nix b/nixos/modules/host/hardware/gpu/amd.nix index e96cf55..ccd580f 100644 --- a/nixos/modules/host/hardware/gpu/amd.nix +++ b/nixos/modules/host/hardware/gpu/amd.nix @@ -9,7 +9,7 @@ inherit (builtins) elem; in { config = mkIf (elem gpu.type ["amd"]) { - hardware.opengl = { + hardware.graphics = { extraPackages = with pkgs; [ vulkan-tools vulkan-loader diff --git a/nixos/modules/host/hardware/gpu/intel.nix b/nixos/modules/host/hardware/gpu/intel.nix index 92ad023..cad8028 100644 --- a/nixos/modules/host/hardware/gpu/intel.nix +++ b/nixos/modules/host/hardware/gpu/intel.nix @@ -11,7 +11,7 @@ in { config = mkIf (elem gpu.type ["intel"]) { services.xserver.videoDrivers = ["modesetting"]; - hardware.opengl = { + hardware.graphics = { extraPackages = with pkgs; [ vaapiIntel vaapiVdpau @@ -29,7 +29,7 @@ in { ]; }; boot.initrd.kernelModules = ["i915"]; - environment.variables = mkIf config.hardware.opengl.enable { + environment.variables = mkIf config.hardware.graphics.enable { VDPAU_DRIVER = "va_gl"; }; }; diff --git a/nixos/modules/host/hardware/gpu/nvidia.nix b/nixos/modules/host/hardware/gpu/nvidia.nix index 870f8e9..56eb86f 100644 --- a/nixos/modules/host/hardware/gpu/nvidia.nix +++ b/nixos/modules/host/hardware/gpu/nvidia.nix @@ -7,25 +7,27 @@ gpu = config.ooknet.host.hardware.gpu; inherit (lib) mkIf mkDefault; inherit (builtins) elem; - production = config.boot.kernelPackages.nvidiaPackages.production; - # beta = config.boot.kernelPackages.nvidiaPackages.beta; + # production = config.boot.kernelPackages.nvidiaPackages.production; + beta = config.boot.kernelPackages.nvidiaPackages.beta; in { # TODO: make option to choose nvidia package - config = mkIf (elem gpu.type ["nvidia"]) { + config = mkIf (gpu.type == "nvidia") { + # need this for wayland + services.xserver.videoDrivers = ["nvidia"]; hardware = { nvidia = { - open = mkDefault true; - package = production; + open = false; + package = beta; forceFullCompositionPipeline = true; nvidiaSettings = false; nvidiaPersistenced = true; modesetting.enable = true; powerManagement = { - enable = mkDefault true; + enable = mkDefault false; finegrained = mkDefault false; }; }; - opengl = { + graphics = { extraPackages = with pkgs; [nvidia-vaapi-driver]; extraPackages32 = with pkgs.pkgsi686Linux; [nvidia-vaapi-driver]; }; @@ -47,5 +49,16 @@ in { LIBVA_DRIVER_NAME = "nvidia"; NVD_BACKEND = "direct"; }; + # https://github.com/ventureoo/nvidia-tweaks + services.udev.extraRules = '' + ACTION=="bind", SUBSYSTEM=="pci", DRIVERS=="nvidia", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", TEST=="power/control", ATTR{power/control}="auto" + ACTION=="unbind", SUBSYSTEM=="pci", DRIVERS=="nvidia", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", TEST=="power/control", ATTR{power/control}="on" + ''; + boot.kernelParams = [ + "nvidia.NVreg_UsePageAttributeTable=1" + "nvidia.NVreg_InitializeSystemMemoryAllocations=0" + "nvidia.NVreg_EnableStreamMemOPs=1" + "nvidia.NVreg_RegistryDwords=__REGISTRYDWORDS" + ]; }; }