fixes for multi gpu
This commit is contained in:
@@ -1,28 +1,26 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkOption types mkIf mkMerge;
|
||||
inherit (lib) mkEnableOption mkOption types mkIf mkMerge flatten concatMap;
|
||||
|
||||
cfg = config.nixos.hardware.graphics;
|
||||
vendor = cfg.vendor;
|
||||
|
||||
# Common packages used across all vendors
|
||||
commonPackages = with pkgs; [
|
||||
libva
|
||||
vaapiVdpau
|
||||
libvdpau-va-gl
|
||||
libGL
|
||||
];
|
||||
|
||||
commonPackages32 = with pkgs.pkgsi686Linux; [
|
||||
libva
|
||||
vaapiVdpau
|
||||
libvdpau-va-gl
|
||||
];
|
||||
|
||||
# Mesa Vulkan packages (used by AMD & Intel only)
|
||||
mesaVulkanPackages = with pkgs; [
|
||||
vulkan-loader
|
||||
vulkan-validation-layers
|
||||
@@ -30,7 +28,6 @@
|
||||
vulkan-utility-libraries
|
||||
];
|
||||
|
||||
# Extra desktop utilities
|
||||
tools = with pkgs; [
|
||||
vulkan-tools
|
||||
wayland
|
||||
@@ -48,18 +45,21 @@
|
||||
export ELECTRON_OZONE_PLATFORM_HINT=auto
|
||||
exec "$@"
|
||||
'';
|
||||
|
||||
hasVendor = vendor: builtins.elem vendor cfg.vendors;
|
||||
in {
|
||||
options.nixos.hardware.graphics = {
|
||||
enable = mkEnableOption "Enable general graphics support";
|
||||
|
||||
vendor = mkOption {
|
||||
type = types.enum ["amd" "intel" "nvidia"];
|
||||
default = "amd";
|
||||
description = "GPU vendor to configure support for.";
|
||||
vendors = mkOption {
|
||||
type = types.listOf (types.enum ["amd" "intel" "nvidia"]);
|
||||
default = ["amd"];
|
||||
description = "List of GPU vendors to configure support for.";
|
||||
};
|
||||
|
||||
nvidia = {
|
||||
open.enable = mkEnableOption "Enable NVidia open drivers";
|
||||
|
||||
package = mkOption {
|
||||
type = types.enum ["stable" "beta" "production" "latest"];
|
||||
default = "stable";
|
||||
@@ -68,70 +68,79 @@ in {
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (
|
||||
mkMerge [
|
||||
{
|
||||
hardware.graphics = {
|
||||
enable = true;
|
||||
enable32Bit = true;
|
||||
};
|
||||
}
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
hardware.graphics = {
|
||||
enable = true;
|
||||
enable32Bit = true;
|
||||
extraPackages = flatten (concatMap (
|
||||
vendor:
|
||||
if vendor == "amd"
|
||||
then commonPackages ++ mesaVulkanPackages
|
||||
else if vendor == "intel"
|
||||
then
|
||||
commonPackages
|
||||
++ mesaVulkanPackages
|
||||
++ (with pkgs; [
|
||||
vpl-gpu-rt
|
||||
intel-media-driver
|
||||
intel-compute-runtime
|
||||
])
|
||||
else if vendor == "nvidia"
|
||||
then
|
||||
commonPackages
|
||||
++ (with pkgs; [
|
||||
nvidiaOffloadScript
|
||||
intel-media-driver
|
||||
nvidia-vaapi-driver
|
||||
vulkan-tools
|
||||
])
|
||||
else []
|
||||
)
|
||||
cfg.vendors);
|
||||
|
||||
# AMD-specific configuration
|
||||
(mkIf (vendor == "amd") {
|
||||
hardware.amdgpu.overdrive.enable = true;
|
||||
hardware.graphics.extraPackages = commonPackages ++ mesaVulkanPackages;
|
||||
hardware.graphics.extraPackages32 = commonPackages32;
|
||||
environment.systemPackages = tools;
|
||||
})
|
||||
extraPackages32 = flatten (concatMap (_: commonPackages32) cfg.vendors);
|
||||
};
|
||||
|
||||
# Intel-specific configuration
|
||||
(mkIf (vendor == "intel") {
|
||||
hardware.graphics.extraPackages =
|
||||
commonPackages
|
||||
++ mesaVulkanPackages
|
||||
++ (with pkgs; [
|
||||
vpl-gpu-rt
|
||||
intel-media-driver
|
||||
intel-compute-runtime
|
||||
]);
|
||||
hardware.graphics.extraPackages32 = commonPackages32;
|
||||
environment.systemPackages = tools;
|
||||
})
|
||||
environment.systemPackages = flatten (concatMap (
|
||||
vendor:
|
||||
if vendor == "amd"
|
||||
then
|
||||
tools
|
||||
++ (with pkgs; [
|
||||
# rocmPackages.rpp
|
||||
# rocmPackages.clr
|
||||
])
|
||||
else if vendor == "intel"
|
||||
then tools
|
||||
else if vendor == "nvidia"
|
||||
then with pkgs; [egl-wayland libGL]
|
||||
else []
|
||||
)
|
||||
cfg.vendors);
|
||||
}
|
||||
|
||||
# Nvidia-specific configuration
|
||||
(mkIf (vendor == "nvidia") {
|
||||
hardware.graphics.extraPackages =
|
||||
commonPackages
|
||||
++ (with pkgs; [
|
||||
nvidiaOffloadScript
|
||||
intel-media-driver
|
||||
nvidia-vaapi-driver
|
||||
vulkan-tools
|
||||
]);
|
||||
hardware.graphics.extraPackages32 = commonPackages32;
|
||||
environment.systemPackages = with pkgs; [
|
||||
egl-wayland
|
||||
libGL
|
||||
];
|
||||
(mkIf (hasVendor "amd") {
|
||||
hardware.amdgpu.overdrive.enable = true;
|
||||
})
|
||||
|
||||
hardware.nvidia = {
|
||||
package =
|
||||
if cfg.nvidia.package == "beta"
|
||||
then config.boot.kernelPackages.nvidiaPackages.beta
|
||||
else if cfg.nvidia.package == "latest"
|
||||
then config.boot.kernelPackages.nvidiaPackages.latest
|
||||
else if cfg.nvidia.package == "production"
|
||||
then config.boot.kernelPackages.nvidiaPackages.production
|
||||
else config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
(mkIf (hasVendor "nvidia") {
|
||||
hardware.nvidia = {
|
||||
package =
|
||||
if cfg.nvidia.package == "beta"
|
||||
then config.boot.kernelPackages.nvidiaPackages.beta
|
||||
else if cfg.nvidia.package == "latest"
|
||||
then config.boot.kernelPackages.nvidiaPackages.latest
|
||||
else if cfg.nvidia.package == "production"
|
||||
then config.boot.kernelPackages.nvidiaPackages.production
|
||||
else config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
|
||||
modesetting.enable = true;
|
||||
powerManagement.enable = false;
|
||||
powerManagement.finegrained = false;
|
||||
open = cfg.nvidia.open.enable;
|
||||
nvidiaSettings = true;
|
||||
};
|
||||
})
|
||||
]
|
||||
);
|
||||
modesetting.enable = true;
|
||||
powerManagement.enable = false;
|
||||
powerManagement.finegrained = false;
|
||||
open = cfg.nvidia.open.enable;
|
||||
nvidiaSettings = true;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ in {
|
||||
cloudflared
|
||||
libargon2
|
||||
openssl
|
||||
xmrig
|
||||
ocl-icd
|
||||
]
|
||||
|
||||
(mkIf cfg.common.enable [
|
||||
|
||||
Reference in New Issue
Block a user