nixos-config/modules/common/hardware.nix

41 lines
887 B
Nix
Raw Normal View History

2024-04-11 20:15:47 +02:00
{
lib,
config,
pkgs,
machineProps,
2024-04-11 20:15:47 +02:00
...
}:
let
hwAccelerationOptionPath = if (machineProps == "unstable") then "graphics" else "opengl";
in
with lib;
{
options.hwAccelerationGPU = mkOption {
2024-04-11 20:15:47 +02:00
type = types.nullOr (
types.enum [
"nvidia"
"intel"
"amd"
]
);
default = null;
example = "nvidia";
description = ''
The GPU type.
'';
};
config = {
2024-04-11 20:15:47 +02:00
boot.kernelParams = mkIf (config.hwAccelerationGPU == "intel") [ "i915.enable_guc=2" ];
2024-02-08 09:59:41 +01:00
# Small hack as this option path changes between 24.05 and unstable
hardware.${hwAccelerationOptionPath} = {
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)
];
};
};
}