nixos-config/modules/common/hardware.nix

33 lines
875 B
Nix
Raw Normal View History

{ lib, config, pkgs, ... }:
with lib;
{
options.hwAccelerationGPU = mkOption {
type = types.nullOr (types.enum [ "nvidia" "intel" ]);
default = null;
example = "nvidia";
description = ''
The GPU type.
'';
};
config = {
2024-02-08 09:59:41 +01:00
boot.kernelParams = mkIf (config.hwAccelerationGPU == "intel") [
"i915.enable_guc=2"
];
hardware.opengl = {
enable = config.hwAccelerationGPU != null;
extraPackages = with pkgs; [
(mkIf (config.hwAccelerationGPU == "intel") intel-media-driver)
2024-02-08 09:59:41 +01:00
(mkIf (config.hwAccelerationGPU == "intel") intel-compute-runtime)
(mkIf (config.hwAccelerationGPU == "nvidia") libvdpau-va-gl)
(mkIf (config.hwAccelerationGPU == "nvidia") vaapiVdpau)
];
};
services.xserver.videoDrivers = [
(mkIf (config.hwAccelerationGPU == "nvidia") "nouveau")
];
};
}