hardware: graphics: update module

Signed-off-by: Bloxx12 <charlie@charlieroot.dev>
Change-Id: I6a6a6964aff2aa0b8443da4726686024c9515490
This commit is contained in:
Bloxx12 2025-07-27 00:45:23 +02:00 committed by fau
commit 1524aa6c1f
No known key found for this signature in database

View file

@ -1,10 +1,11 @@
{ {
config, config,
lib, lib,
pkgs,
... ...
}: }:
let let
inherit (lib.modules) mkIf; inherit (lib.modules) mkDefault mkIf;
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
cfg = config.modules.system.hardware; cfg = config.modules.system.hardware;
@ -18,12 +19,21 @@ in
}; };
config = { config = {
hardware = { hardware = {
graphics.enable = true; graphics = {
nvidia = mkIf cfg.nvidia.enable { enable = true;
# we want the open-source drivers extraPackages = [ pkgs.nvidia-vaapi-driver ];
open = true; };
nvidia = mkIf cfg.nvidia.enable {
open = mkDefault true;
# Whether to enable kernel modesetting when using the NVIDIA proprietary driver.
# Enabling this causes the proprietary NVIDIA driver to provide its own
# framebuffer device, which can cause Wayland compositors to work when
# they otherwise wouldnt. .
modesetting.enable = true; modesetting.enable = true;
# nvidia-settings is useless on NixOS.
nvidiaSettings = false; nvidiaSettings = false;
# fixes sleep on nvidia devices # fixes sleep on nvidia devices
@ -34,6 +44,27 @@ in
package = config.boot.kernelPackages.nvidiaPackages.beta; package = config.boot.kernelPackages.nvidiaPackages.beta;
}; };
}; };
services.xserver.videoDrivers = mkIf cfg.nvidia.enable [ "nvidia" ]; services.xserver.videoDrivers = [
"nvidia"
];
environment.systemPackages = builtins.attrValues {
inherit (pkgs)
mesa
vulkan-tools
vulkan-loader
libva
libva-utils
;
inherit (pkgs.nvtopPackages) nvidia;
};
# Nouveau is a set of free and open-source drivers for NVIDIA GPUs
# that provide 2D/3D acceleration for all NVIDIA GPUs.
# Its use is in general not recommended due to its considerably worse
# performance compared to NVIDIA's kernel modules, as it does not
# support reclocking (changing the GPU clock frequency on-demand)
# for many NVIDIA GPUs.
# I therefore disable it to save myself from headaches.
boot.blacklistedKernelModules = mkIf cfg.nvidia.enable [ "nouveau" ];
}; };
} }