From b568b0b796964e5501a2f56cfafc1939c351724a Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Thu, 21 May 2026 19:53:27 -0400 Subject: [PATCH] archinstall_adapter: pass --config/--creds via synthetic sys.argv (env vars don't work) ArchConfigHandler reads --config and --creds from sys.argv via argparse at construction time; it ignores ARCHINSTALL_CONFIG/ARCHINSTALL_CREDS env vars (confirmed in archinstall 4.3 lib/args.py:_parse_args). Setting those env vars was a no-op, so handler.config.disk_config was always None when the wrapper stripped our args off the real argv. Fix: build a synthetic argv [prog, --config , --creds ] and swap it into sys.argv just for the ArchConfigHandler() call, then restore. Drops the unused 'import os' now that the env var lines are gone. --- .../orchestrator/archinstall_adapter.py | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/configs/airootfs/usr/share/omarchy-iso/orchestrator/archinstall_adapter.py b/configs/airootfs/usr/share/omarchy-iso/orchestrator/archinstall_adapter.py index 5327f3c..7c94ce9 100644 --- a/configs/airootfs/usr/share/omarchy-iso/orchestrator/archinstall_adapter.py +++ b/configs/airootfs/usr/share/omarchy-iso/orchestrator/archinstall_adapter.py @@ -35,7 +35,6 @@ correctly, on its first install. from __future__ import annotations -import os from contextlib import contextmanager from pathlib import Path from typing import Iterator @@ -54,11 +53,26 @@ from archinstall.lib.models.users import User def load_arch_config(config_path: Path, creds_path: Path) -> ArchConfigHandler: - """Build an ArchConfigHandler from on-disk JSON. archinstall reads the - paths via env vars, so we set them before instantiating the handler.""" - os.environ["ARCHINSTALL_CONFIG"] = str(config_path) - os.environ["ARCHINSTALL_CREDS"] = str(creds_path) - return ArchConfigHandler() + """Build an ArchConfigHandler from on-disk JSON. + + archinstall's ArchConfigHandler reads --config / --creds from sys.argv + via argparse at construction time (lib/args.py:_parse_args). It does + NOT consult env vars for these paths. We can't pass them on our real + argv because the wrapper strips them before exec'ing Python (so other + archinstall arg-parsing code doesn't choke on our flags), so we hand + archinstall a synthetic argv just for this call. + """ + import sys + saved_argv = sys.argv + sys.argv = [ + saved_argv[0] if saved_argv else "omarchy-install", + "--config", str(config_path), + "--creds", str(creds_path), + ] + try: + return ArchConfigHandler() + finally: + sys.argv = saved_argv def make_mirror_handler(offline: bool = True) -> MirrorListHandler: