diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index aa8a600836..5af72b0763 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -43,6 +43,7 @@ class GfxPackage(Enum): LibvaIntelDriver = 'libva-intel-driver' LibvaNvidiaDriver = 'libva-nvidia-driver' Mesa = 'mesa' + NvidiaOpen = 'nvidia-open' NvidiaOpenDkms = 'nvidia-open-dkms' VulkanIntel = 'vulkan-intel' VulkanRadeon = 'vulkan-radeon' diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py index 02243ec0ac..1145a09411 100644 --- a/archinstall/lib/profile/profiles_handler.py +++ b/archinstall/lib/profile/profiles_handler.py @@ -10,7 +10,7 @@ from typing import TYPE_CHECKING, NotRequired, TypedDict from archinstall.default_profiles.profile import GreeterType, Profile -from archinstall.lib.hardware import GfxDriver +from archinstall.lib.hardware import GfxDriver, GfxPackage from archinstall.lib.models.profile import ProfileConfiguration from archinstall.lib.networking import fetch_data_from_url from archinstall.lib.output import debug, error, info @@ -222,13 +222,22 @@ def install_greeter(self, install_session: Installer, greeter: GreeterType) -> N def install_gfx_driver(self, install_session: Installer, driver: GfxDriver) -> None: debug(f'Installing GFX driver: {driver.value}') - if driver in [GfxDriver.NvidiaOpenKernel]: - headers = [f'{kernel}-headers' for kernel in install_session.kernels] - # Fixes https://github.com/archlinux/archinstall/issues/585 - install_session.add_additional_packages(headers) - driver_pkgs = driver.gfx_packages() pkg_names = [p.value for p in driver_pkgs] + + # For Nvidia open kernel modules, use nvidia-open instead of nvidia-open-dkms + # when all selected kernels are mainline (no dkms needed). This avoids + # installing dkms + kernel headers and speeds up installation. + if driver == GfxDriver.NvidiaOpenKernel: + needs_dkms = any('-' in k for k in install_session.kernels) + + if needs_dkms: + headers = [f'{kernel}-headers' for kernel in install_session.kernels] + install_session.add_additional_packages(headers) + else: + pkg_names = [GfxPackage.NvidiaOpen.value if p == GfxPackage.NvidiaOpenDkms.value else p for p in pkg_names] + pkg_names = [p for p in pkg_names if p != GfxPackage.Dkms.value] + install_session.add_additional_packages(pkg_names) def install_profile_config(self, install_session: Installer, profile_config: ProfileConfiguration) -> None: