hardware/graphics: add AMD option
Some checks are pending
/ Build Nix targets (push) Waiting to run

This commit is contained in:
Felix Buehler 2025-05-04 13:41:46 +02:00
parent 981c43c186
commit ca9a3149a5
2 changed files with 35 additions and 17 deletions

View file

@ -17,14 +17,15 @@ in
my.hardware = {
bluetooth.enable = true;
debug.enable = true;
drive-monitor = {
enable = true;
};
drive-monitor.enable = true;
firmware = {
enable = true;
inherit cpuFlavor;
};
graphics.cpuFlavor = cpuFlavor;
graphics = {
enable = true;
inherit cpuFlavor;
};
id-card.enable = true;
keychron.enable = true;
monitor.enable = true;

View file

@ -9,29 +9,46 @@ let
in
{
options.my.hardware.graphics = with lib; {
enable = mkEnableOption "graphics configuration";
cpuFlavor = mkOption {
type = with types; nullOr (enum [ "intel" ]);
type =
with types;
nullOr (enum [
"amd"
"intel"
]);
default = null;
example = "intel";
description = "Which kind of GPU";
};
};
config = lib.mkMerge [
# Intel GPU
(lib.mkIf (cfg.cpuFlavor == "intel") {
nixpkgs.config.packageOverrides = pkgs: {
vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
};
hardware.graphics = {
enable = true;
extraPackages = with pkgs; [
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; [
intel-media-driver # LIBVA_DRIVER_NAME=iHD
vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
vaapiVdpau
libvdpau-va-gl
];
};
})
];
})
(lib.mkIf (cfg.cpuFlavor == "amd") {
hardware.graphics.extraPackages = with pkgs; [
amdvlk
];
hardware.graphics.extraPackages32 = with pkgs; [
driversi686Linux.amdvlk
];
})
]
);
}