diff --git a/archinstall/lib/global_menu.py b/archinstall/lib/global_menu.py index 8c13daf402..cbf4651715 100644 --- a/archinstall/lib/global_menu.py +++ b/archinstall/lib/global_menu.py @@ -472,7 +472,7 @@ def _prev_profile(self, item: MenuItem) -> str | None: output += profile_config.profile.name + '\n' if profile_config.gfx_driver: - output += tr('Graphics driver') + ': ' + profile_config.gfx_driver.value + '\n' + output += tr('Graphics driver') + ': ' + profile_config.gfx_driver.value[1] + '\n' if profile_config.greeter: output += tr('Greeter') + ': ' + profile_config.greeter.value + '\n' diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index e1278dfad4..abf4c67a94 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -2,6 +2,7 @@ from enum import Enum from functools import cached_property from pathlib import Path +from typing import Any from .exceptions import SysCallError from .general import SysCommand @@ -43,8 +44,8 @@ class GfxPackage(Enum): LibvaMesaDriver = 'libva-mesa-driver' LibvaNvidiaDriver = 'libva-nvidia-driver' Mesa = 'mesa' - NvidiaDkms = 'nvidia-dkms' - NvidiaOpenDkms = 'nvidia-open-dkms' + Nvidia = 'nvidia-open' + NvidiaDkms = 'nvidia-open-dkms' VulkanIntel = 'vulkan-intel' VulkanRadeon = 'vulkan-radeon' VulkanNouveau = 'vulkan-nouveau' @@ -56,17 +57,23 @@ class GfxPackage(Enum): class GfxDriver(Enum): - AllOpenSource = 'All open-source' - AmdOpenSource = 'AMD / ATI (open-source)' - IntelOpenSource = 'Intel (open-source)' - NvidiaOpenKernel = 'Nvidia (open kernel module for newer GPUs, Turing+)' - NvidiaOpenSource = 'Nvidia (open-source nouveau driver)' - NvidiaProprietary = 'Nvidia (proprietary)' - VMOpenSource = 'VirtualBox (open-source)' - - def is_nvidia(self) -> bool: + MesaAll = ('mesa_all', 'All open-source') + MesaAmd = ('mesa_amd', 'AMD / ATI (open-source)') + MesaIntel = ('mesa_intel', 'Intel (open-source)') + Nvidia = ('nvidia', 'Nvidia (official open kernel module, for newer GPUs, Turing+)') + MesaNvidia = ('mesa_nvidia', 'Nvidia (open-source nouveau driver)') + MesaVirtualized = ('mesa_vm', 'VirtualBox (open-source)') + + @classmethod + def from_key(cls, key: str) -> Any: + for member in cls: + if member.value[0] == key: + return member + return None + + def has_dkms_variant(self) -> bool: match self: - case GfxDriver.NvidiaProprietary | GfxDriver.NvidiaOpenSource | GfxDriver.NvidiaOpenKernel: + case GfxDriver.Nvidia: return True case _: return False @@ -84,7 +91,7 @@ def gfx_packages(self) -> list[GfxPackage]: packages = [GfxPackage.XorgServer, GfxPackage.XorgXinit] match self: - case GfxDriver.AllOpenSource: + case GfxDriver.MesaAll: packages += [ GfxPackage.Mesa, GfxPackage.Xf86VideoAmdgpu, @@ -97,7 +104,7 @@ def gfx_packages(self) -> list[GfxPackage]: GfxPackage.VulkanIntel, GfxPackage.VulkanNouveau, ] - case GfxDriver.AmdOpenSource: + case GfxDriver.MesaAmd: packages += [ GfxPackage.Mesa, GfxPackage.Xf86VideoAmdgpu, @@ -105,33 +112,26 @@ def gfx_packages(self) -> list[GfxPackage]: GfxPackage.LibvaMesaDriver, GfxPackage.VulkanRadeon, ] - case GfxDriver.IntelOpenSource: + case GfxDriver.MesaIntel: packages += [ GfxPackage.Mesa, GfxPackage.LibvaIntelDriver, GfxPackage.IntelMediaDriver, GfxPackage.VulkanIntel, ] - case GfxDriver.NvidiaOpenKernel: + case GfxDriver.Nvidia: packages += [ - GfxPackage.NvidiaOpenDkms, - GfxPackage.Dkms, + GfxPackage.Nvidia, GfxPackage.LibvaNvidiaDriver, ] - case GfxDriver.NvidiaOpenSource: + case GfxDriver.MesaNvidia: packages += [ GfxPackage.Mesa, GfxPackage.Xf86VideoNouveau, GfxPackage.LibvaMesaDriver, GfxPackage.VulkanNouveau, ] - case GfxDriver.NvidiaProprietary: - packages += [ - GfxPackage.NvidiaDkms, - GfxPackage.Dkms, - GfxPackage.LibvaNvidiaDriver, - ] - case GfxDriver.VMOpenSource: + case GfxDriver.MesaVirtualized: packages += [ GfxPackage.Mesa, ] diff --git a/archinstall/lib/interactions/system_conf.py b/archinstall/lib/interactions/system_conf.py index 0c0e54aaee..9d16edbf63 100644 --- a/archinstall/lib/interactions/system_conf.py +++ b/archinstall/lib/interactions/system_conf.py @@ -55,9 +55,9 @@ def select_driver(options: list[GfxDriver] = [], preset: GfxDriver | None = None if not options: options = [driver for driver in GfxDriver] - items = [MenuItem(o.value, value=o, preview_action=lambda x: x.value.packages_text()) for o in options] + items = [MenuItem(o.value[1], value=o, preview_action=lambda x: x.value.packages_text()) for o in options] group = MenuItemGroup(items, sort_items=True) - group.set_default_by_value(GfxDriver.AllOpenSource) + group.set_default_by_value(GfxDriver.MesaAll) if preset is not None: group.set_focus_by_value(preset) @@ -68,7 +68,7 @@ def select_driver(options: list[GfxDriver] = [], preset: GfxDriver | None = None if SysInfo.has_intel_graphics(): header += tr('For the best compatibility with your Intel hardware, you may want to use either the all open-source or Intel options.\n') if SysInfo.has_nvidia_graphics(): - header += tr('For the best compatibility with your Nvidia hardware, you may want to use the Nvidia proprietary driver.\n') + header += tr('For the best compatibility with your NVIDIA hardware, you may want to use the official NVIDIA driver.\n') result = SelectMenu[GfxDriver]( group, diff --git a/archinstall/lib/models/profile.py b/archinstall/lib/models/profile.py index 80cbde7a19..5aff6a3a6e 100644 --- a/archinstall/lib/models/profile.py +++ b/archinstall/lib/models/profile.py @@ -17,6 +17,26 @@ class _ProfileConfigurationSerialization(TypedDict): greeter: str | None +def _parse_gfx_driver(value: str) -> GfxDriver: + # A really ugly hack to deal with older configs that use values + # instead of keys for their config. + match value: + case 'All open-source': + return GfxDriver.MesaAll + case 'AMD / ATI (open-source)': + return GfxDriver.MesaAmd + case 'Intel (open-source)': + return GfxDriver.MesaIntel + case 'Nvidia (open kernel module for newer GPUs, Turing+)': + return GfxDriver.Nvidia + case 'Nvidia (open-source nouveau driver)' | 'Nvidia (proprietary)': + return GfxDriver.MesaNvidia + case 'VirtualBox (open-source)': + return GfxDriver.MesaVirtualized + + return GfxDriver.from_key(value) + + @dataclass class ProfileConfiguration: profile: Profile | None = None @@ -28,7 +48,7 @@ def json(self) -> _ProfileConfigurationSerialization: return { 'profile': profile_handler.to_json(self.profile), - 'gfx_driver': self.gfx_driver.value if self.gfx_driver else None, + 'gfx_driver': self.gfx_driver.value[0] if self.gfx_driver else None, 'greeter': self.greeter.value if self.greeter else None, } @@ -42,6 +62,6 @@ def parse_arg(cls, arg: _ProfileConfigurationSerialization) -> 'ProfileConfigura return ProfileConfiguration( profile, - GfxDriver(gfx_driver) if gfx_driver else None, + _parse_gfx_driver(gfx_driver) if gfx_driver else None, GreeterType(greeter) if greeter else None, ) diff --git a/archinstall/lib/profile/profile_menu.py b/archinstall/lib/profile/profile_menu.py index d434fc2fb3..36976e5b43 100644 --- a/archinstall/lib/profile/profile_menu.py +++ b/archinstall/lib/profile/profile_menu.py @@ -77,7 +77,7 @@ def _select_profile(self, preset: Profile | None) -> Profile | None: self._item_group.find_by_key('gfx_driver').value = None else: self._item_group.find_by_key('gfx_driver').enabled = True - self._item_group.find_by_key('gfx_driver').value = GfxDriver.AllOpenSource + self._item_group.find_by_key('gfx_driver').value = GfxDriver.MesaAll if not profile.is_greeter_supported(): self._item_group.find_by_key('greeter').enabled = False @@ -100,8 +100,10 @@ def _select_gfx_driver(self, preset: GfxDriver | None = None) -> GfxDriver | Non driver = select_driver(preset=preset) if driver and 'Sway' in profile.current_selection_names(): - if driver.is_nvidia(): - header = tr('The proprietary Nvidia driver is not supported by Sway.') + '\n' + # Sway only cares about the official NVIDIA driver in this situation + # see: https://github.com/swaywm/sway/blob/238f0d4a8b399f0df6791c47eb54c8636722d5a9/sway/server.c#L165 + if driver == GfxDriver.Nvidia: + header = tr('The official NVIDIA driver is not supported by Sway.') + '\n' header += tr('It is likely that you will run into issues, are you okay with that?') + '\n' group = MenuItemGroup.yes_no() @@ -124,7 +126,7 @@ def _select_gfx_driver(self, preset: GfxDriver | None = None) -> GfxDriver | Non def _prev_gfx(self, item: MenuItem) -> str | None: if item.value: - driver = item.get_value().value + driver = item.get_value().value[1] packages = item.get_value().packages_text() return f'Driver: {driver}\n{packages}' return None diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py index cfe85de913..5ac879e27c 100644 --- a/archinstall/lib/profile/profiles_handler.py +++ b/archinstall/lib/profile/profiles_handler.py @@ -13,7 +13,7 @@ from archinstall.lib.translationhandler import tr from ...default_profiles.profile import GreeterType, Profile -from ..hardware import GfxDriver +from ..hardware import GfxDriver, GfxPackage from ..models.profile import ProfileConfiguration from ..networking import fetch_data_from_url, list_interfaces from ..output import debug, error, info @@ -222,14 +222,26 @@ def install_greeter(self, install_session: 'Installer', greeter: GreeterType) -> file.write(filedata) def install_gfx_driver(self, install_session: 'Installer', driver: GfxDriver) -> None: - debug(f'Installing GFX driver: {driver.value}') + debug(f'Installing GFX driver: {driver.value[1]}') + + driver_pkgs = driver.gfx_packages() + # All non-standard kernel packages have a '-' in their name. + # ex: 'linux-zen' and 'linux-lts' + is_dkms_needed = any('-' in s for s in install_session.kernels) + + if driver.has_dkms_variant() and is_dkms_needed: + debug(f'A non-standard kernel was selected, installing DKMS variant of {driver.value[1]}') - if driver in [GfxDriver.NvidiaOpenKernel, GfxDriver.NvidiaProprietary]: 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() + driver_pkgs.append(GfxPackage.Dkms) + + match driver: + case GfxDriver.Nvidia: + driver_pkgs.remove(GfxPackage.Nvidia) + driver_pkgs.append(GfxPackage.NvidiaDkms) + pkg_names = [p.value for p in driver_pkgs] install_session.add_additional_packages(pkg_names) diff --git a/archinstall/locales/base.pot b/archinstall/locales/base.pot index 67da11b2ab..89c6a61080 100644 --- a/archinstall/locales/base.pot +++ b/archinstall/locales/base.pot @@ -193,8 +193,8 @@ msgid "" msgstr "" msgid "" -"For the best compatibility with your Nvidia hardware, you may want to use " -"the Nvidia proprietary driver.\n" +"For the best compatibility with your NVIDIA hardware, you may want to use " +"the official NVIDIA driver.\n" msgstr "" msgid "" @@ -1051,7 +1051,7 @@ msgid "Environment type: {}" msgstr "" msgid "" -"The proprietary Nvidia driver is not supported by Sway. It is likely that " +"The official NVIDIA driver is not supported by Sway. It is likely that " "you will run into issues, are you okay with that?" msgstr "" @@ -1488,7 +1488,7 @@ msgstr "" msgid "Info" msgstr "" -msgid "The proprietary Nvidia driver is not supported by Sway." +msgid "The official NVIDIA driver is not supported by Sway." msgstr "" msgid "It is likely that you will run into issues, are you okay with that?" diff --git a/examples/config-sample.json b/examples/config-sample.json index 30ba5b52d3..bbd25b66bb 100644 --- a/examples/config-sample.json +++ b/examples/config-sample.json @@ -135,7 +135,7 @@ "packages": [], "parallel downloads": 0, "profile_config": { - "gfx_driver": "All open-source (default)", + "gfx_driver": "mesa_all", "greeter": "sddm", "profile": { "details": [ diff --git a/examples/custom-command-sample.json b/examples/custom-command-sample.json index 8a82d0127a..315f90ee2b 100644 --- a/examples/custom-command-sample.json +++ b/examples/custom-command-sample.json @@ -18,7 +18,7 @@ "packages": ["docker", "git", "wget", "zsh"], "services": ["docker"], "profile": "gnome", - "gfx_driver": "All open-source (default)", + "gfx_driver": "mesa_all", "swap": true, "sys-encoding": "utf-8", "sys-language": "en_US", diff --git a/tests/data/test_config.json b/tests/data/test_config.json index a01c831b7f..21401a5467 100644 --- a/tests/data/test_config.json +++ b/tests/data/test_config.json @@ -179,7 +179,7 @@ ], "parallel_downloads": 66, "profile_config": { - "gfx_driver": "All open-source", + "gfx_driver": "mesa_all", "greeter": "lightdm-gtk-greeter", "profile": { "custom_settings": { diff --git a/tests/test_args.py b/tests/test_args.py index 87ab1a3f47..0c84b6d1a7 100644 --- a/tests/test_args.py +++ b/tests/test_args.py @@ -178,7 +178,7 @@ def test_config_file_parsing( 'main': 'Desktop', } ), - gfx_driver=GfxDriver.AllOpenSource, + gfx_driver=GfxDriver.MesaAll, greeter=GreeterType.Lightdm, ), mirror_config=MirrorConfiguration(