[M5+] add resolver::nixpkgs_probe (nix eval wrapper)
This commit is contained in:
@@ -1,5 +1,29 @@
|
||||
export module cargoxx.resolver;
|
||||
|
||||
import std;
|
||||
import cargoxx.util;
|
||||
import cargoxx.exec;
|
||||
import cargoxx.linkdb;
|
||||
|
||||
export namespace cargoxx::resolver {
|
||||
|
||||
// What `nix eval nixpkgs#<pkg>` reports for a package: a confirmation that
|
||||
// the attribute exists, a best-effort version string, and the realized
|
||||
// nix-store path so later probes can scan its installed CMake configs.
|
||||
struct NixpkgsInfo {
|
||||
std::string attr; // the queried name, e.g. "simdjson"
|
||||
std::string version; // empty when the derivation has no version
|
||||
std::string out_path; // absolute /nix/store/... path
|
||||
};
|
||||
|
||||
// Pure parser exposed for unit testing. Accepts the raw JSON returned by
|
||||
// `nix eval --json --apply 'p: { ... }'` and extracts NixpkgsInfo.
|
||||
auto parse_nix_eval_json(std::string_view attr, std::string_view json)
|
||||
-> util::Result<NixpkgsInfo>;
|
||||
|
||||
// Runs `nix eval nixpkgs#<attr> --json --apply ...` via exec::run. Returns
|
||||
// `ResolutionUnknownPackage` when the attribute is missing,
|
||||
// `ResolutionNetworkError` on timeout or evaluator errors.
|
||||
auto nixpkgs_probe(const std::string& attr) -> util::Result<NixpkgsInfo>;
|
||||
|
||||
} // namespace cargoxx::resolver
|
||||
|
||||
Reference in New Issue
Block a user