[M5+] add resolver::nixpkgs_probe (nix eval wrapper)

This commit is contained in:
2026-05-10 09:52:06 +00:00
parent f3d18b7939
commit 1c7ff39f64
7 changed files with 239 additions and 0 deletions

View File

@@ -78,6 +78,17 @@ All notable changes to cargoxx will be documented in this file.
and `[build]` honoring `warnings_as_errors` and `sanitizers`. Source
paths emitted relative to `build/` (i.e. prefixed with `../`).
Output is deterministic. `tests/codegen_cmake.cpp` covers 11 cases.
- `cargoxx.resolver::nixpkgs_probe(attr)` — runs
`nix eval nixpkgs#<attr> --json --apply 'p: { version, path }'` via
`exec::run` and returns a `NixpkgsInfo { attr, version, out_path }`.
Distinguishes missing attributes (`ResolutionUnknownPackage`) from
evaluator/network errors (`ResolutionNetworkError`). The `path` field
name avoids nix's `outPath`-driven derivation coercion in `--json`
mode (which would otherwise serialize the result as a bare path
string instead of a JSON object). Pure parser
`parse_nix_eval_json(attr, text)` exposed for unit tests; live tests
in `tests/nixpkgs_probe_live.cpp` are gated behind
`CARGOXX_NETWORK_TESTS=1` (verified locally against `hello`).
- `cargoxx add <pkg>[@<version>] [--components a,b]` edits `Cargoxx.toml`,
validates the new dep against the curated linkdb (so unknown packages
and missing components fail before any disk write), and rejects