nichts/modules/system/hardware/graphics.mod.nix

71 lines
1.9 KiB
Nix
Raw Normal View History

{
config,
lib,
pkgs,
...
}:
let
inherit (lib.modules) mkDefault mkIf;
inherit (lib.options) mkEnableOption;
2024-08-16 23:31:12 +02:00
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 ];
};
2024-08-16 23:31:12 +02:00
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. .
2024-08-16 23:31:12 +02:00
modesetting.enable = true;
# nvidia-settings is useless on NixOS.
nvidiaSettings = false;
# fixes sleep on nvidia devices
2024-08-16 23:31:12 +02:00
powerManagement = {
enable = true;
finegrained = false;
};
2024-08-16 23:05:45 +02:00
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" ];
};
}