Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/profile
diff options
context:
space:
mode:
authorDaniel Girtler <blackrabbit256@gmail.com>2023-06-21 17:52:48 +1000
committerGitHub <noreply@github.com>2023-06-21 09:52:48 +0200
commitc7c34c9e704b880ba0ad26696946b6561d2ee784 (patch)
treec9af72ab0f93f85c87b0fddcbd6c25776c2d7ad2 /archinstall/lib/profile
parent16132e6fc9d54f237f260227f99dad5b639891db (diff)
Make Gfx driver handling saver (#1885)
Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
Diffstat (limited to 'archinstall/lib/profile')
-rw-r--r--archinstall/lib/profile/profile_menu.py15
-rw-r--r--archinstall/lib/profile/profile_model.py8
-rw-r--r--archinstall/lib/profile/profiles_handler.py11
3 files changed, 17 insertions, 17 deletions
diff --git a/archinstall/lib/profile/profile_menu.py b/archinstall/lib/profile/profile_menu.py
index 213466a6..079a9817 100644
--- a/archinstall/lib/profile/profile_menu.py
+++ b/archinstall/lib/profile/profile_menu.py
@@ -4,9 +4,9 @@ from typing import TYPE_CHECKING, Any, Optional, Dict
from archinstall.default_profiles.profile import Profile, GreeterType
from .profile_model import ProfileConfiguration
-from ..hardware import AVAILABLE_GFX_DRIVERS
from ..menu import Menu, MenuSelectionType, AbstractSubMenu, Selector
from ..interactions.system_conf import select_driver
+from ..hardware import GfxDriver
if TYPE_CHECKING:
_: Any
@@ -38,7 +38,7 @@ class ProfileMenu(AbstractSubMenu):
self._menu_options['gfx_driver'] = Selector(
_('Graphics driver'),
lambda preset: self._select_gfx_driver(preset),
- display_func=lambda x: x if x else None,
+ display_func=lambda x: x.value if x else None,
dependencies=['profile'],
default=self._preset.gfx_driver if self._preset.profile and self._preset.profile.is_graphic_driver_supported() else None,
enabled=self._preset.profile.is_graphic_driver_supported() if self._preset.profile else False
@@ -73,7 +73,7 @@ class ProfileMenu(AbstractSubMenu):
self._menu_options['gfx_driver'].set_current_selection(None)
else:
self._menu_options['gfx_driver'].set_enabled(True)
- self._menu_options['gfx_driver'].set_current_selection('All open-source (default)')
+ self._menu_options['gfx_driver'].set_current_selection(GfxDriver.AllOpenSource)
if not profile.is_greeter_supported():
self._menu_options['greeter'].set_enabled(False)
@@ -87,7 +87,7 @@ class ProfileMenu(AbstractSubMenu):
return profile
- def _select_gfx_driver(self, preset: Optional[str] = None) -> Optional[str]:
+ def _select_gfx_driver(self, preset: Optional[GfxDriver] = None) -> Optional[GfxDriver]:
driver = preset
profile: Optional[Profile] = self._menu_options['profile'].current_selection
@@ -96,11 +96,8 @@ class ProfileMenu(AbstractSubMenu):
driver = select_driver(current_value=preset)
if driver and 'Sway' in profile.current_selection_names():
- packages = AVAILABLE_GFX_DRIVERS[driver]
-
- if packages and "nvidia" in packages:
- prompt = str(
- _('The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues, are you okay with that?'))
+ if driver.is_nvidia():
+ prompt = str(_('The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues, are you okay with that?'))
choice = Menu(prompt, Menu.yes_no(), default_option=Menu.no(), skip=False).run()
if choice.value == Menu.no():
diff --git a/archinstall/lib/profile/profile_model.py b/archinstall/lib/profile/profile_model.py
index ad3015ae..2b52073a 100644
--- a/archinstall/lib/profile/profile_model.py
+++ b/archinstall/lib/profile/profile_model.py
@@ -3,6 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Optional, Dict
+from ..hardware import GfxDriver
from archinstall.default_profiles.profile import Profile, GreeterType
if TYPE_CHECKING:
@@ -12,14 +13,14 @@ if TYPE_CHECKING:
@dataclass
class ProfileConfiguration:
profile: Optional[Profile] = None
- gfx_driver: Optional[str] = None
+ gfx_driver: Optional[GfxDriver] = None
greeter: Optional[GreeterType] = None
def json(self) -> Dict[str, Any]:
from .profiles_handler import profile_handler
return {
'profile': profile_handler.to_json(self.profile),
- 'gfx_driver': self.gfx_driver,
+ 'gfx_driver': self.gfx_driver.value if self.gfx_driver else None,
'greeter': self.greeter.value if self.greeter else None
}
@@ -27,9 +28,10 @@ class ProfileConfiguration:
def parse_arg(cls, arg: Dict[str, Any]) -> 'ProfileConfiguration':
from .profiles_handler import profile_handler
greeter = arg.get('greeter', None)
+ gfx_driver = arg.get('gfx_driver', None)
return ProfileConfiguration(
profile_handler.parse_profile_config(arg['profile']),
- arg.get('gfx_driver', None),
+ GfxDriver(gfx_driver) if gfx_driver else None,
GreeterType(greeter) if greeter else None
)
diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py
index 2cc15d8e..4e7c3d2b 100644
--- a/archinstall/lib/profile/profiles_handler.py
+++ b/archinstall/lib/profile/profiles_handler.py
@@ -11,7 +11,7 @@ from typing import List, TYPE_CHECKING, Any, Optional, Dict, Union
from archinstall.default_profiles.profile import Profile, TProfile, GreeterType
from .profile_model import ProfileConfiguration
-from ..hardware import AVAILABLE_GFX_DRIVERS
+from ..hardware import GfxDriver, GfxPackage
from ..menu import MenuSelectionType, Menu, MenuSelection
from ..networking import list_interfaces, fetch_data_from_url
from ..output import error, debug, info, warn
@@ -188,17 +188,18 @@ class ProfileHandler:
if service:
install_session.enable_service(service)
- def install_gfx_driver(self, install_session: 'Installer', driver: str):
+ def install_gfx_driver(self, install_session: 'Installer', driver: Optional[GfxDriver]):
try:
- driver_pkgs = AVAILABLE_GFX_DRIVERS[driver] if driver else []
- additional_pkg = ' '.join(['xorg-server', 'xorg-xinit'] + driver_pkgs)
+ driver_pkgs = driver.packages() if driver else []
+ pkg_names = [p.value for p in driver_pkgs]
+ additional_pkg = ' '.join(['xorg-server', 'xorg-xinit'] + pkg_names)
if driver is not None:
# Find the intersection between the set of known nvidia drivers
# and the selected driver packages. Since valid intesections can
# only have one element or none, we iterate and try to take the
# first element.
- if driver_pkg := next(iter({'nvidia','nvidia-open'} & set(driver_pkgs)), None):
+ if driver_pkg := next(iter({GfxPackage.Nvidia, GfxPackage.NvidiaOpen} & set(driver_pkgs)), None):
if any(kernel in install_session.base_packages for kernel in ("linux-lts", "linux-zen")):
for kernel in install_session.kernels:
# Fixes https://github.com/archlinux/archinstall/issues/585