ix-config
Hierarchical configuration loading for Ixchel. Provides a consistent config loading pattern across CLI tools in the ecosystem.
Why
Ixchel tools share common configuration patterns:
- Global config in
~/.ixchel/config/ - Project config in
.ixchel/ - Environment variable overrides
- Shared settings (GitHub token, embedding model, etc.)
This crate centralizes that logic to avoid divergence.
Directory Structure
Ixchel uses a unified ~/.ixchel/ directory for global config/state/data:
~/.ixchel/ # Unified ixchel home
├── config/ # Configuration (user-editable TOML)
│ ├── config.toml # Shared settings (GitHub token, embedding model)
│ └── ixchel.toml # ixchel settings
│
├── data/ # Caches & databases (auto-generated)
├── state/ # Runtime metadata (ephemeral)
└── log/ # Operation logs
Project-local overrides:
{project}/.ixchel/ # Project config + canonical artifacts
├── config.toml # Project shared config
├── ixchel.toml # ixchel project overrides
└── ...
See the Configuration docs for full details.
Configuration Hierarchy
Priority (highest to lowest):
1. Environment variables (IXCHEL_*, GITHUB_TOKEN, etc.)
2. Global tool config (~/.ixchel/config/<tool>.toml)
3. Global shared config (~/.ixchel/config/config.toml)
4. Project tool config (.ixchel/<tool>.toml)
5. Project shared config (.ixchel/config.toml)
6. Defaults (from Default trait)
Usage
use ;
use Deserialize;
// Simple loading with defaults
let config: MyToolConfig = load_config?;
// Or with more control
let loader = new;
let config: MyToolConfig = loader
.with_env_prefix
.load?;
Shared Config
The global ~/.ixchel/config/config.toml contains settings shared across tools:
[]
= "ghp_xxx" # Or use GITHUB_TOKEN env var
[]
= "BAAI/bge-small-en-v1.5"
= 32
[]
= "helixdb"
= "data/ixchel" # relative to .ixchel/
Path Helpers
use ;
// Get the Ixchel home directory
let home = ixchel_home; // ~/.ixchel
// Get specific subdirectories
let config_dir = ixchel_config_dir; // ~/.ixchel/config
let data_dir = ixchel_data_dir; // ~/.ixchel/data
// Tool-specific data directories
let index_dir = ixchel_data_dir.join; // ~/.ixchel/data/index
GitHub Token Detection
The crate provides automatic GitHub token detection:
use detect_github_token;
if let Some = detect_github_token
Detection order:
GITHUB_TOKENenvironment variableGH_TOKENenvironment variablegithub.tokenin config filesgh auth tokencommand output
Environment Variables
# Override ixchel home directory
# Shared settings
# Tool-specific overrides (using __ for nesting)
Consumers (current)
| Crate | Notes |
|---|---|
ix-core |
Loads merged Ixchel config |
ix-embeddings |
Reads embedding settings from config |
ix-app |
Selects backends for apps |
Specifications
- specs/requirements.md - Requirements in EARS notation
- specs/design.md - Design decisions and API details
- specs/tasks.md - Implementation plan and backlog