From c1eae10e93a94edbd0f9b94da4ad3d1c73ae993c Mon Sep 17 00:00:00 2001 From: HADEON <52324046+h8d13@users.noreply.github.com> Date: Sun, 28 Dec 2025 01:09:37 +0100 Subject: [PATCH] Enable IWD to be used as back-end in network selection (#4025) * feedback * feedback2 * Refactor for less duplicate code and more conscise logic Group NM types and handle configurations appropriatly - For IWD -> Copy from ISO + Disable standalone and configure back-end - For standard -> Install wpa_supplicant - For both install applet only when Desktop profile Added comments for clearer logic * Rem comments * Rem copy to ISO * the one commit to rule them all --- archinstall/default_profiles/desktop.py | 1 - archinstall/lib/installer.py | 8 ++++++ archinstall/lib/interactions/network_menu.py | 2 ++ archinstall/lib/models/network.py | 26 ++++++++++++++++---- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/archinstall/default_profiles/desktop.py b/archinstall/default_profiles/desktop.py index 9bd65b44..ab582186 100644 --- a/archinstall/default_profiles/desktop.py +++ b/archinstall/default_profiles/desktop.py @@ -32,7 +32,6 @@ class DesktopProfile(Profile): 'wget', 'iwd', 'wireless_tools', - 'wpa_supplicant', 'smartmontools', 'xdg-utils', ] diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 93829ecc..32ada064 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -768,6 +768,14 @@ class Installer: return True + def configure_nm_iwd(self) -> None: + # Create NetworkManager config directory and write iwd backend conf + nm_conf_dir = self.target / 'etc/NetworkManager/conf.d' + nm_conf_dir.mkdir(parents=True, exist_ok=True) + + iwd_backend_conf = nm_conf_dir / 'wifi_backend.conf' + iwd_backend_conf.write_text('[device]\nwifi.backend=iwd\n') + def mkinitcpio(self, flags: list[str]) -> bool: for plugin in plugins.values(): if hasattr(plugin, 'on_mkinitcpio'): diff --git a/archinstall/lib/interactions/network_menu.py b/archinstall/lib/interactions/network_menu.py index 14071ef2..7ab2a1f3 100644 --- a/archinstall/lib/interactions/network_menu.py +++ b/archinstall/lib/interactions/network_menu.py @@ -212,6 +212,8 @@ def ask_to_configure_network(preset: NetworkConfiguration | None) -> NetworkConf return NetworkConfiguration(NicType.ISO) case NicType.NM: return NetworkConfiguration(NicType.NM) + case NicType.NM_IWD: + return NetworkConfiguration(NicType.NM_IWD) case NicType.MANUAL: preset_nics = preset.nics if preset else [] nics = ManualNetworkConfig(tr('Configure interfaces'), preset_nics).run() diff --git a/archinstall/lib/models/network.py b/archinstall/lib/models/network.py index 88f52fd6..69acc068 100644 --- a/archinstall/lib/models/network.py +++ b/archinstall/lib/models/network.py @@ -17,6 +17,7 @@ if TYPE_CHECKING: class NicType(Enum): ISO = 'iso' NM = 'nm' + NM_IWD = 'nm_iwd' MANUAL = 'manual' def display_msg(self) -> str: @@ -24,7 +25,9 @@ class NicType(Enum): case NicType.ISO: return tr('Copy ISO network configuration to installation') case NicType.NM: - return tr('Use NetworkManager (necessary to configure internet graphically in GNOME and KDE Plasma)') + return tr('Use Network Manager (default backend)') + case NicType.NM_IWD: + return tr('Use Network Manager (iwd backend)') case NicType.MANUAL: return tr('Manual configuration') @@ -147,16 +150,29 @@ class NetworkConfiguration: installation.copy_iso_network_config( enable_services=True, # Sources the ISO network configuration to the install medium. ) - case NicType.NM: - installation.add_additional_packages(['networkmanager']) + case NicType.NM | NicType.NM_IWD: + # Install NetworkManager package for both cases + packages = ['networkmanager'] + # Defautl back-end only for non-iwd + if self.type == NicType.NM: + packages.append('wpa_supplicant') + + installation.add_additional_packages(packages) + + # Desktop profile -> Always add applet if profile_config and profile_config.profile: if profile_config.profile.is_desktop_profile(): - installation.add_additional_packages(['network-manager-applet']) + installation.add_additional_packages('network-manager-applet') + installation.enable_service('NetworkManager.service') + if self.type == NicType.NM_IWD: + # NM_IWD special handling + installation.configure_nm_iwd() + installation.disable_service('iwd.service') + case NicType.MANUAL: for nic in self.nics: installation.configure_nic(nic) - installation.enable_service('systemd-networkd') installation.enable_service('systemd-resolved')