NixOS-Config/modules/system/devices/video/nvidia/default.nix
2024-11-18 17:14:02 -05:00

39 lines
1.3 KiB
Nix

{ lib, pkgs, config, ... }:
{
options.system.video = {
nvidia = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable the proprietary Nvidia stack";
};
};
nouveau = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable the open-source Nouveau driver";
};
};
};
config = {
# Conditionally set video drivers based on the options
services.xserver.videoDrivers =
if config.system.video.nvidia.enable then [ "nvidia" ]
else if config.system.video.nouveau.enable then [ "nouveau" ]
else [];
# Configure Nvidia settings if Nvidia is enabled
hardware = {
nvidia = lib.mkIf config.system.video.nvidia.enable {
modesetting.enable = true;
nvidiaSettings = false;
package = config.boot.kernelPackages.nvidiaPackages.beta;
open = false;
};
opengl.extraPackages = with pkgs; [ nvidia-vaapi-driver ];
};
};
}