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 = { my.hardware = {
bluetooth.enable = true; bluetooth.enable = true;
debug.enable = true; debug.enable = true;
drive-monitor = { drive-monitor.enable = true;
enable = true;
};
firmware = { firmware = {
enable = true; enable = true;
inherit cpuFlavor; inherit cpuFlavor;
}; };
graphics.cpuFlavor = cpuFlavor; graphics = {
enable = true;
inherit cpuFlavor;
};
id-card.enable = true; id-card.enable = true;
keychron.enable = true; keychron.enable = true;
monitor.enable = true; monitor.enable = true;

View file

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