diff options
author | Jon Santmyer <jon@jonsantmyer.com> | 2024-01-07 12:00:08 -0500 |
---|---|---|
committer | Jon Santmyer <jon@jonsantmyer.com> | 2024-01-07 12:00:08 -0500 |
commit | 7b79203f54853733d4fae88943829d0e24e6e49f (patch) | |
tree | a352d199fad7453332b9308a6295164157729f27 /modules/hardware/gpu.nix | |
parent | 184bd30bcb303104a4981ac742d8f8961c5477e7 (diff) | |
download | nix-config-7b79203f54853733d4fae88943829d0e24e6e49f.tar.gz nix-config-7b79203f54853733d4fae88943829d0e24e6e49f.tar.bz2 nix-config-7b79203f54853733d4fae88943829d0e24e6e49f.zip |
massive overhaul
Diffstat (limited to 'modules/hardware/gpu.nix')
-rw-r--r-- | modules/hardware/gpu.nix | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/modules/hardware/gpu.nix b/modules/hardware/gpu.nix new file mode 100644 index 0000000..d7dfe17 --- /dev/null +++ b/modules/hardware/gpu.nix @@ -0,0 +1,61 @@ +{ + config, + options, + lib, + pkgs, + ... +}: let + gpuConfig = config.modules.hardware.gpu; + device = config.modules.device; +in { + options.modules.hardware.gpu = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + }; + }; + + config = lib.mkIf (gpuConfig.enable) (lib.mkMerge [ + { + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + } + (lib.mkIf (device.gpu == "intel") { + boot.initrd.kernelModules = ["i915"]; + services.xserver.videoDrivers = ["modesetting"]; + + hardware.opengl.extraPackages = [ + pkgs.intel-compute-runtime + pkgs.intel-media-driver + pkgs.vaapiIntel + pkgs.vaapiVdpau + pkgs.libvdpau-va-gl + ]; + + environment.variables.VDPAU_DRIVER = "va_gl"; + }) + (lib.mkIf (device.gpu == "nvidia") { + services.xserver.videoDrivers = ["nvidia"]; + hardware.nvidia = { + modesetting.enable = true; + powerManagement.enable = false; + powerManagement.finegrained = false; + open = false; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.beta; + }; + boot.initrd.kernelModules = [ + "nvidia" + "nvidia_modeset" + "nvidia_uvm" + "nvidia_drm" + ]; + boot.extraModprobeConfig = '' + options modeset=1 fbdev=1 + ''; + }) + ]); +} |