From 3e7ea0bf7b87a9f835bdaf424e1e93e954ca567a Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sun, 11 Aug 2024 14:51:55 -0500 Subject: [PATCH] feat(hosts/orion): enable Nvidia GPU w/ PRIME --- hosts/orion/modules/graphical.nix | 8 ----- hosts/orion/modules/hardware.nix | 57 ++++++++++++++++--------------- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/hosts/orion/modules/graphical.nix b/hosts/orion/modules/graphical.nix index cebc17f4..e98244f4 100644 --- a/hosts/orion/modules/graphical.nix +++ b/hosts/orion/modules/graphical.nix @@ -28,13 +28,5 @@ ]; }; }; - hardware.graphics = { - enable = true; - extraPackages = with pkgs; [ - intel-media-driver - intel-vaapi-driver - libvdpau - ]; - }; services.spice-vdagentd.enable = true; } diff --git a/hosts/orion/modules/hardware.nix b/hosts/orion/modules/hardware.nix index 63be4045..c5ccf901 100644 --- a/hosts/orion/modules/hardware.nix +++ b/hosts/orion/modules/hardware.nix @@ -1,30 +1,31 @@ +{ pkgs, config, ... }: { - inputs, - lib, - pkgs, - ... -}: - -{ - # NOTE: Disable Nvidia GPU - boot.extraModprobeConfig = '' - blacklist nouveau - options nouveau iwlwifi power_save=1 modeset=0 - ''; - services.udev.extraRules = '' - # Remove NVIDIA USB xHCI Host Controller devices, if present - ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{power/control}="auto", ATTR{remove}="1" - # Remove NVIDIA USB Type-C UCSI devices, if present - ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{power/control}="auto", ATTR{remove}="1" - # Remove NVIDIA Audio devices, if present - ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto", ATTR{remove}="1" - # Remove NVIDIA VGA/3D controller devices - ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1" - ''; - boot.blacklistedKernelModules = [ - "nouveau" - "nvidia" - "nvidia_drm" - "nvidia_modeset" - ]; + services.xserver.videoDrivers = [ "nvidia" ]; + environment.variables.VDPAU_DRIVER = "va_gl"; + hardware = { + enableRedistributableFirmware = true; + graphics = { + enable = true; + extraPackages = with pkgs; [ + vpl-gpu-rt + intel-media-driver + intel-vaapi-driver + libvdpau-va-gl + nvidia-vaapi-driver + ]; + extraPackages32 = with pkgs.driversi686Linux; [ intel-vaapi-driver ]; + }; + nvidia = { + package = config.boot.kernelPackages.nvidiaPackages.beta; + powerManagement.enable = true; + prime = { + offload = { + enable = true; + enableOffloadCmd = true; + }; + nvidiaBusId = "PCI:1:0:0"; + intelBusId = "PCI:0:2:0"; + }; + }; + }; }