nixos-config/modules/common/hardware.nix
2024-08-01 21:40:51 +02:00

42 lines
833 B
Nix

{
lib,
config,
pkgs,
machineProps,
...
}:
let
gpu = config.my.hardware.gpu;
hwAccelerationOptionPath = if (machineProps == "unstable") then "graphics" else "opengl";
in
with lib;
{
options.my.hardware.gpu = mkOption {
type = types.nullOr (
types.enum [
"nvidia"
"intel"
"amd"
]
);
default = null;
example = "nvidia";
description = ''
The GPU type.
'';
};
config = {
boot.kernelParams = mkIf (gpu == "intel") [ "i915.enable_guc=2" ];
# Small hack as this option path changes between 24.05 and unstable
hardware.${hwAccelerationOptionPath} = {
enable = gpu != null;
extraPackages = with pkgs; [
(mkIf (gpu == "intel") intel-media-driver)
(mkIf (gpu == "intel") intel-compute-runtime)
];
};
};
}