nixos/modules/hardware/graphics/default.nix

55 lines
1.2 KiB
Nix
Raw Normal View History

2024-07-28 21:08:02 +02:00
{
config,
lib,
pkgs,
...
}:
2023-03-19 14:42:42 +01:00
let
cfg = config.my.hardware.graphics;
in
{
options.my.hardware.graphics = with lib; {
2025-05-04 13:41:46 +02:00
enable = mkEnableOption "graphics configuration";
2023-03-19 14:42:42 +01:00
cpuFlavor = mkOption {
2025-05-04 13:41:46 +02:00
type =
with types;
nullOr (enum [
"amd"
"intel"
]);
2023-03-19 14:42:42 +01:00
default = null;
example = "intel";
description = "Which kind of GPU";
};
};
2025-05-04 13:41:46 +02:00
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
hardware.graphics.enable = true;
}
# Intel GPU
(lib.mkIf (cfg.cpuFlavor == "intel") {
nixpkgs.config.packageOverrides = pkgs: {
vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
};
hardware.graphics.extraPackages = with pkgs; [
2023-03-19 14:42:42 +01:00
intel-media-driver # LIBVA_DRIVER_NAME=iHD
vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
vaapiVdpau
libvdpau-va-gl
];
2025-05-04 13:41:46 +02:00
})
(lib.mkIf (cfg.cpuFlavor == "amd") {
hardware.graphics.extraPackages = with pkgs; [
amdvlk
];
hardware.graphics.extraPackages32 = with pkgs; [
driversi686Linux.amdvlk
];
})
]
);
2023-03-19 14:42:42 +01:00
}