From c67c6b7fcced5f015cc4446c472e1733fc3315dc Mon Sep 17 00:00:00 2001 From: Foo the Frog Date: Mon, 24 Jun 2024 01:18:11 +0600 Subject: [PATCH] Update config removing deprecated options --- modules/foundations/graphics/amd.nix | 8 ++++ modules/foundations/graphics/default.nix | 11 ++++++ modules/foundations/graphics/nvidia.nix | 50 ++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 modules/foundations/graphics/amd.nix create mode 100644 modules/foundations/graphics/default.nix create mode 100644 modules/foundations/graphics/nvidia.nix diff --git a/modules/foundations/graphics/amd.nix b/modules/foundations/graphics/amd.nix new file mode 100644 index 0000000..2bb2c95 --- /dev/null +++ b/modules/foundations/graphics/amd.nix @@ -0,0 +1,8 @@ +{ + config, + lib, + ... +}: { + boot.kernelModules = ["kvm-amd"]; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/modules/foundations/graphics/default.nix b/modules/foundations/graphics/default.nix new file mode 100644 index 0000000..c4f3572 --- /dev/null +++ b/modules/foundations/graphics/default.nix @@ -0,0 +1,11 @@ +{...}: { + imports = [ + ./amd.nix + ./nvidia.nix + ]; + + hardware.graphics = { + enable = true; + enable32Bit = true; + }; +} diff --git a/modules/foundations/graphics/nvidia.nix b/modules/foundations/graphics/nvidia.nix new file mode 100644 index 0000000..5aead87 --- /dev/null +++ b/modules/foundations/graphics/nvidia.nix @@ -0,0 +1,50 @@ +{ + config, + pkgs, + ... +}: { + # Load Nvidia driver (works for both X and Wayland) + services.xserver.videoDrivers = ["nvidia"]; + + boot = { + kernelModules = ["nvidia" "nvidia_modeset" "nvidia_uvm" "nvidia_drm" "i2c-nvidia_gpu"]; + blacklistedKernelModules = ["nouveau"]; + }; + + hardware.nvidia = { + package = config.boot.kernelPackages.nvidiaPackages.latest; + modesetting.enable = true; + + powerManagement = { + # NOTE: Currently experimental + enable = false; + finegrained = false; + }; + + nvidiaSettings = true; # NOTE: It enables the `nvidia-settings` command + open = false; + nvidiaPersistenced = true; + + # Enable NVIDIA Optimus (Offload) + prime = { + offload = { + enable = true; + enableOffloadCmd = true; + }; + + amdgpuBusId = "PCI:5:0:0"; # Integrated + nvidiaBusId = "PCI:1:0:0"; # Dedicated + }; + }; + + environment.sessionVariables = { + LIBVA_DRIVER_NAME = "nvidia"; + VDPAU_DRIVER = "va_gl"; + __GLX_VENDOR_LIBRARY_NAME = "nvidia"; + }; + + hardware.graphics.extraPackages = with pkgs; [ + vaapiVdpau + nvidia-vaapi-driver + ]; +}