nichts/modules/system/hardware/graphics.mod.nix
Bloxx12 1524aa6c1f
hardware: graphics: update module
Signed-off-by: Bloxx12 <charlie@charlieroot.dev>
Change-Id: I6a6a6964aff2aa0b8443da4726686024c9515490
2025-07-27 00:52:41 +02:00

70 lines
1.9 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
config,
lib,
pkgs,
...
}:
let
inherit (lib.modules) mkDefault mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.modules.system.hardware;
in
{
options.modules.system.hardware = {
nvidia = {
enable = mkEnableOption "Nvidia graphics drivers";
};
amd.enable = mkEnableOption "AMD graphics drivers";
};
config = {
hardware = {
graphics = {
enable = true;
extraPackages = [ pkgs.nvidia-vaapi-driver ];
};
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;
# nvidia-settings is useless on NixOS.
nvidiaSettings = false;
# fixes sleep on nvidia devices
powerManagement = {
enable = true;
finegrained = false;
};
package = config.boot.kernelPackages.nvidiaPackages.beta;
};
};
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" ];
};
}