From 5115850da7ffbfab2d63d8e047dc445c36c1a668 Mon Sep 17 00:00:00 2001 From: bcumming Date: Mon, 6 Jul 2026 17:43:49 +0200 Subject: [PATCH] fix: preserve source_cache config when writing install_tree Merge install_tree into any config.yaml already written by the mirror layer instead of overwriting it, so source_cache from mirrors is kept. Co-Authored-By: Claude Opus 4.8 (1M context) --- stackinator/builder.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stackinator/builder.py b/stackinator/builder.py index e5f3602..d6b422f 100644 --- a/stackinator/builder.py +++ b/stackinator/builder.py @@ -260,8 +260,14 @@ def generate(self, recipe): with (config_path / "packages.yaml").open("w") as f: f.write(yaml.dump(recipe.packages["build"])) - config_yaml = {"config": {"install_tree": {"root": str(recipe.mount)}}} - with (config_path / "config.yaml").open("w") as f: + # Merge install_tree into any config.yaml the mirror layer already wrote + # (e.g. config:source_cache from mirrors.yaml at lines 167-170 above). + config_file = config_path / "config.yaml" + config_yaml = {} + if config_file.exists(): + config_yaml = yaml.safe_load(config_file.read_text()) or {} + config_yaml.setdefault("config", {})["install_tree"] = {"root": str(recipe.mount)} + with config_file.open("w") as f: f.write(yaml.dump(config_yaml)) # Add custom spack package recipes, configured via Spack repos.