[M6] Phase 2 self-hosting: cargoxx builds itself from Cargoxx.toml

This commit is contained in:
2026-05-15 13:14:28 +00:00
parent 73aebf183e
commit c46f3aa1f0
7 changed files with 394 additions and 152 deletions

View File

@@ -619,18 +619,17 @@ User-facing errors are formatted via `util::format(Error)` and printed to stderr
## 15. Bootstrap and self-hosting
Three phases.
**Phase 0 (historical) — hand-written `CMakeLists.txt` and `flake.nix` at the repo root.**
**Phase 0 — hand-written CMake (commits before milestone M3).**
`CMakeLists.txt` and `flake.nix` at the repo root are written by humans. `cargoxx` builds `cargoxx`.
**Phase 2 (current, since M6) — fully self-hosted.**
`Cargoxx.toml` describes cargoxx's own deps with nixpkgs names: `sqlite`, `reproc`, `catch2_3`. `cargoxx build` runs the auto-resolver chain (nixpkgs probe → realize → nix_cmake_scan → pc_scan), confirms each recipe via verify_link, and generates `build/CMakeLists.txt` and the root `flake.nix`. Both files are committed (tracked) so the build is reproducible without first building cargoxx, and `[build].include_dirs = ["third_party"]` keeps the vendored headers on the include path.
**Phase 1 — generated CMake, hand-written flake.**
At milestone M3 (codegen complete), commit a populated `Cargoxx.toml`. Generate `build/CMakeLists.txt` from it. Delete the root `CMakeLists.txt`. The root `flake.nix` stays hand-written because cargoxx doesn't know about its own host-language deps yet.
Bootstrap path:
```
pre-built cargoxx → cargoxx build → next cargoxx
```
**Phase 2 — fully self-hosted.**
At milestone M5, vendor all third-party headers into `third_party/` and have cargoxx generate the flake too. The bootstrap path becomes: pre-built cargoxx binary → run `cargoxx build` → produce next cargoxx.
For continuity, ship a known-good cargoxx binary as a release artifact. Anyone bootstrapping from source clones the repo, downloads the latest release binary, and runs `./bootstrap-cargoxx build`. If we ever want to bootstrap from absolute zero, `scripts/bootstrap-build.sh` does it with a hand-written CMake invocation.
A clean clone with an empty `~/.cache/cargoxx/linkdb.sqlite` auto-resolves all three deps on first `cargoxx build` (sqlite goes through pkg-config because nixpkgs ships no SQLite3Config.cmake; reproc/catch2_3 go through nix_cmake_scan). For continuity, a known-good cargoxx binary is shipped as a release artifact; from-scratch bootstrap is not in v0.1 scope.
---