[M5+] nix-cmake-scan walks the dev output for multi-output packages

This commit is contained in:
2026-05-10 13:29:45 +00:00
parent 1604b1d5a8
commit 54da546ebc
5 changed files with 80 additions and 8 deletions

View File

@@ -15,8 +15,14 @@ namespace {
// `outPath` is a magic attribute name that triggers nix's derivation
// coercion in --json mode (the attrset gets serialized as a bare path
// string). Renaming the field to `path` keeps it a proper JSON object.
//
// `dev_path` is captured for multi-output packages (boost, openssl,
// llvm, …) where CMake configs live under the `dev` output rather
// than `out`. `p ? dev` is false for single-output packages, leaving
// the field as the empty string.
constexpr std::string_view APPLY_FN =
"p: { version = p.version or \"\"; path = p.outPath; }";
"p: { version = p.version or \"\"; path = p.outPath; "
"dev_path = if p ? dev then p.dev.outPath else \"\"; }";
auto make_error(util::ErrorCode code, std::string msg) -> util::Error {
return util::Error{code, std::move(msg), "", std::nullopt, std::nullopt};
@@ -48,7 +54,9 @@ auto parse_nix_eval_json(std::string_view attr, std::string_view json)
"nix eval JSON is not an object"));
}
NixpkgsInfo info{.attr = std::string{attr}, .version = {}, .out_path = {}};
NixpkgsInfo info{
.attr = std::string{attr}, .version = {}, .out_path = {}, .dev_path = {},
};
if (j.contains("path") && j["path"].is_string()) {
info.out_path = j["path"].get<std::string>();
@@ -62,6 +70,10 @@ auto parse_nix_eval_json(std::string_view attr, std::string_view json)
info.version = j["version"].get<std::string>();
}
if (j.contains("dev_path") && j["dev_path"].is_string()) {
info.dev_path = j["dev_path"].get<std::string>();
}
return info;
}