Configuration Management
Relevant source files
The following files were used as context for generating this wiki page:
The abx-dl configuration system is a multi-layered architecture designed to manage global settings, plugin-specific options, and runtime-derived data. It leverages environment variables, persistent .env files, and Pydantic-based validation to ensure type safety and consistency across the CLI and the underlying plugin ecosystem.
The system distinguishes between user-defined preferences and "derived" configuration. User preferences are stored in a static configuration file, while derived data—such as resolved paths to external binaries or installation timestamps—are handled as a separate cache layer to ensure that the environment remains portable and reproducible. Sources: abx_dl/config.py:1-12, README.md:65-75
Architecture and Data Layers
The configuration management system utilizes a hierarchical structure for resolving settings. Values are prioritized starting from CLI arguments, followed by environment variables, and finally the persistent configuration files. Sources: README.md:92-98, abx_dl/config.py:218-230
Configuration Files
The project maintains two distinct files within the configuration directory (defaulting to ~/.config/abx/):
| File | Description | Purpose |
|---|---|---|
config.env | User-provided values | Stores persistent settings like TIMEOUT or USER_AGENT. |
derived.env | Runtime-derived cache | Stores resolved *_BINARY paths and ABX_INSTALL_CACHE. |
Sources: abx_dl/config.py:37-43, README.md:65-70
Data Flow Diagram
The following diagram illustrates how the MachineService and configuration loaders resolve the final environment used by plugin hooks.
Global Configuration
Global settings are managed via the GlobalConfig Pydantic class. This class handles default values, environment variable prefixes, and path derivation for the runtime environment. Sources: abx_dl/config.py:46-64
Core Global Settings
| Option | Type | Default | Description |
|---|---|---|---|
TIMEOUT | int | 60 | Default timeout for hooks in seconds. |
USER_AGENT | str | Mozilla/5.0... | Default browser user agent string. |
CHECK_SSL_VALIDITY | bool | True | Whether to verify SSL certificates. |
DATA_DIR | Path | CWD | Base directory for downloads and indices. |
CONFIG_DIR | Path | ~/.config/abx | Directory for storing configuration files. |
CHROME_SANDBOX | str | true | Sandbox setting for Chrome-based plugins. |
Sources: abx_dl/config.py:53-73
Runtime Path Derivation
The system automatically derives specific subdirectories based on the CONFIG_DIR and DATA_DIR. These include LIB_DIR (for binaries), PERSONAS_DIR (for browser profiles), and various package manager homes (PIP_HOME, NPM_HOME). Sources: abx_dl/config.py:81-105
Plugin Configuration
Plugins define their own configuration schemas within a config.json file located in the plugin directory. These schemas include metadata, required dependencies, and specific configuration properties. Sources: abx_dl/models.py:82-90, abx_dl/config.py:315-322
Plugin Schema Components
- Properties: A JSONSchema-formatted dictionary describing configurable keys (e.g.,
WGET_BINARY). - Required Binaries: A list of
RequiredBinaryobjects specifying names and preferredbinproviders(env, apt, brew, npm, etc.). - Required Plugins: A list of other plugins that must be enabled for this plugin to function.
Sources: abx_dl/models.py:65-90
Plugin Environment Hydration
When a plugin hook is executed, the PluginEnv class assembles a flat environment. This process overlays global settings with plugin-specific properties and injects runtime-managed binary directories into the PATH. Sources: abx_dl/models.py:114-140, abx_dl/models.py:168-185
CLI Configuration Management
The abx-dl config command provides an interface for inspecting and modifying persistent settings. Sources: abx_dl/cli.py:900-910
- View Config:
abx-dl configdisplays all settings grouped by section (Global vs. Plugin). - Get Value:
abx-dl config --get TIMEOUTretrieves a specific value after resolving any aliases. - Set Value:
abx-dl config --set WGET_ENABLED=falsevalidates and persists the change toconfig.env.
Sources: README.md:72-78, abx_dl/cli.py:928-950
Alias Resolution
The configuration system supports aliases to simplify user interaction. For example, setting USE_WGET=false is automatically resolved to the canonical WGET_ENABLED=false key based on the plugin's defined properties. Sources: README.md:88-90, abx_dl/config.py:255-265
Binary and Derived Cache
To avoid redundant discovery and installation, abx-dl caches the results of binary resolution in derived.env. Sources: abx_dl/config.py:290-305
- Authority: If a user provides an absolute path in
config.env(e.g.,CHROME_BINARY=/usr/bin/google-chrome), it is authoritative. - Cache: If a bare name is used, the system checks
derived.envfor a previously resolved absolute path. - Validation: Cached paths are validated at runtime; if a binary is missing or stale, the
BinaryRequestflow is re-triggered.
Sources: README.md:100-110, abx_dl/config.py:150-165
Summary
The configuration management system in abx-dl provides a robust, dual-layered approach to settings. By separating user preferences (config.env) from runtime cache (derived.env), it maintains environment stability while allowing for dynamic binary resolution. This architecture ensures that plugin hooks operate in a deterministic environment with all necessary dependencies and global overrides correctly injected via the process environment. Sources: abx_dl/config.py:1-12, README.md:144-155