diff --git a/modules/system/hardware/graphics.mod.nix b/modules/system/hardware/graphics.mod.nix index ffd09ea..063e26e 100644 --- a/modules/system/hardware/graphics.mod.nix +++ b/modules/system/hardware/graphics.mod.nix @@ -1,10 +1,11 @@ { config, lib, + pkgs, ... }: let - inherit (lib.modules) mkIf; + inherit (lib.modules) mkDefault mkIf; inherit (lib.options) mkEnableOption; cfg = config.modules.system.hardware; @@ -18,12 +19,21 @@ in }; config = { hardware = { - graphics.enable = true; - nvidia = mkIf cfg.nvidia.enable { - # we want the open-source drivers - open = true; + 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 wouldn’t. . modesetting.enable = true; + + # nvidia-settings is useless on NixOS. nvidiaSettings = false; # fixes sleep on nvidia devices @@ -34,6 +44,27 @@ in 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" ]; }; }