Files
euri-mklive/euri_mklive/config.py
T
c-ludenberg 3c5a357cb4 euri-mklive: universal CLI ISO builder
- any distro from any distro (debian, ubuntu, arch, artix, void, alpine, fedora)
- YAML config for distro, arch, init, packages, users, services, bootloader
- each distro backend knows how to bootstrap itself
- squashfs + xorriso for ISO generation
- sexy CLI with banner and colored output
- examples for Artix+Euri and Project Horizon
2026-08-26 19:01:19 +02:00

36 lines
854 B
Python

"""YAML config loader and validator."""
from __future__ import annotations
from pathlib import Path
from typing import Any
import yaml
REQUIRED = {"distro", "arch"}
def load(path: Path) -> dict[str, Any]:
"""Load and validate a YAML config file."""
with open(path) as f:
cfg = yaml.safe_load(f)
if not isinstance(cfg, dict):
raise ValueError(f"Config must be a YAML mapping, got {type(cfg).__name__}")
missing = REQUIRED - cfg.keys()
if missing:
raise ValueError(f"Missing required fields: {', '.join(sorted(missing))}")
# defaults
cfg.setdefault("hostname", "euri")
cfg.setdefault("users", [])
cfg.setdefault("services", [])
cfg.setdefault("packages", [])
cfg.setdefault("init", "dinit")
cfg.setdefault("bootloader", "grub")
cfg.setdefault("iso", {})
return cfg