updated modules to work for cloud
This commit is contained in:
@ -1,42 +1,107 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
nixosModules.gpuHardware = {gpuVendor ? null, ...}: {
|
||||
hardware.opengl = {
|
||||
# Always enable OpenGL support
|
||||
enable = true;
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.graphics;
|
||||
in {
|
||||
options.graphics = {
|
||||
gpuVendor = mkOption {
|
||||
type = types.enum ["nvidia" "amd" "intel" "none"];
|
||||
default = "none";
|
||||
description = "GPU vendor to configure graphics drivers for";
|
||||
};
|
||||
|
||||
# Dynamically select packages based on GPU vendor
|
||||
extraPackages = with pkgs; (
|
||||
# Base packages that are always included
|
||||
[
|
||||
mesa
|
||||
libvdpau-va-gl
|
||||
libva
|
||||
libva-utils
|
||||
]
|
||||
# Vendor-specific packages
|
||||
++ (
|
||||
if gpuVendor == "intel"
|
||||
then [
|
||||
intel-vaapi-driver
|
||||
intel-media-driver
|
||||
]
|
||||
else if gpuVendor == "amd"
|
||||
then [
|
||||
rocm-opencl-icd
|
||||
]
|
||||
else if gpuVendor == "nvidia"
|
||||
then [
|
||||
# Add Nvidia-specific packages if needed
|
||||
nvidia-vaapi-driver
|
||||
]
|
||||
else []
|
||||
)
|
||||
);
|
||||
enable = mkEnableOption "graphics configuration";
|
||||
|
||||
wayland = {
|
||||
enable = mkEnableOption "Wayland support";
|
||||
|
||||
variableRefreshRate = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable variable refresh rate (FreeSync/G-Sync) support";
|
||||
};
|
||||
};
|
||||
|
||||
vulkan = {
|
||||
enable = mkEnableOption "Vulkan support";
|
||||
|
||||
debug = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable Vulkan validation layers";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
glxinfo
|
||||
vulkan-tools
|
||||
mesa-demos
|
||||
];
|
||||
}
|
||||
|
||||
(mkIf (cfg.gpuVendor == "nvidia") {
|
||||
services.xserver.videoDrivers = ["nvidia"];
|
||||
hardware.nvidia = {
|
||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
open = true;
|
||||
modesetting.enable = true;
|
||||
powerManagement.enable = true;
|
||||
};
|
||||
environment.systemPackages = with pkgs; [
|
||||
nvidia-vaapi-driver
|
||||
nvtopPackages.full
|
||||
];
|
||||
})
|
||||
|
||||
(mkIf (cfg.gpuVendor == "amd") {
|
||||
services.xserver.videoDrivers = ["amdgpu"];
|
||||
hardware.opengl.extraPackages = with pkgs; [
|
||||
rocm-opencl-icd
|
||||
rocm-opencl-runtime
|
||||
amdvlk
|
||||
];
|
||||
environment.systemPackages = with pkgs; [
|
||||
radeontop
|
||||
];
|
||||
})
|
||||
|
||||
(mkIf (cfg.gpuVendor == "intel") {
|
||||
services.xserver.videoDrivers = ["modesetting"];
|
||||
hardware.opengl.extraPackages = with pkgs; [
|
||||
intel-media-driver
|
||||
intel-compute-runtime
|
||||
];
|
||||
})
|
||||
|
||||
(mkIf cfg.wayland.enable {
|
||||
programs.xwayland.enable = true;
|
||||
environment.sessionVariables = {
|
||||
MOZ_ENABLE_WAYLAND = "1";
|
||||
QT_QPA_PLATFORM = "wayland";
|
||||
SDL_VIDEODRIVER = "wayland";
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.vulkan.enable {
|
||||
environment.systemPackages = with pkgs;
|
||||
[
|
||||
vulkan-loader
|
||||
vulkan-validation-layers
|
||||
]
|
||||
++ (
|
||||
if cfg.vulkan.debug
|
||||
then [
|
||||
vulkan-tools
|
||||
]
|
||||
else []
|
||||
);
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user