mirror of
https://github.com/NixOS/nix
synced 2025-07-09 07:53:55 +02:00
Scrap ParsedDerivation
for parts
Only a much smaller `StructuredAttrs` remains, the rest is is now moved to `DerivationOptions`. This gets us quite close to `std::optional<StructuredAttrs>` and `DerivationOptions` being included in `Derivation` as fields.
This commit is contained in:
parent
1e31b60043
commit
d8be4f618f
10 changed files with 213 additions and 220 deletions
|
@ -544,10 +544,12 @@ static void main_nix_build(int argc, char * * argv)
|
|||
env["NIX_STORE"] = store->storeDir;
|
||||
env["NIX_BUILD_CORES"] = std::to_string(settings.buildCores);
|
||||
|
||||
ParsedDerivation parsedDrv(drv.env);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(drv.env);
|
||||
DerivationOptions drvOptions;
|
||||
try {
|
||||
drvOptions = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
drvOptions = DerivationOptions::fromStructuredAttrs(
|
||||
drv.env,
|
||||
parsedDrv ? &*parsedDrv : nullptr);
|
||||
} catch (Error & e) {
|
||||
e.addTrace({}, "while parsing derivation '%s'", store->printStorePath(packageInfo.requireDrvPath()));
|
||||
throw;
|
||||
|
@ -566,7 +568,7 @@ static void main_nix_build(int argc, char * * argv)
|
|||
|
||||
std::string structuredAttrsRC;
|
||||
|
||||
if (parsedDrv.hasStructuredAttrs()) {
|
||||
if (parsedDrv) {
|
||||
StorePathSet inputs;
|
||||
|
||||
std::function<void(const StorePath &, const DerivedPathMap<StringSet>::ChildNode &)> accumInputClosure;
|
||||
|
@ -584,24 +586,22 @@ static void main_nix_build(int argc, char * * argv)
|
|||
for (const auto & [inputDrv, inputNode] : drv.inputDrvs.map)
|
||||
accumInputClosure(inputDrv, inputNode);
|
||||
|
||||
if (auto structAttrs = parsedDrv.prepareStructuredAttrs(
|
||||
*store,
|
||||
drvOptions,
|
||||
inputs,
|
||||
drv.outputs))
|
||||
{
|
||||
auto json = structAttrs.value();
|
||||
structuredAttrsRC = writeStructuredAttrsShell(json);
|
||||
auto json = parsedDrv->prepareStructuredAttrs(
|
||||
*store,
|
||||
drvOptions,
|
||||
inputs,
|
||||
drv.outputs);
|
||||
|
||||
auto attrsJSON = (tmpDir.path() / ".attrs.json").string();
|
||||
writeFile(attrsJSON, json.dump());
|
||||
structuredAttrsRC = StructuredAttrs::writeShell(json);
|
||||
|
||||
auto attrsSH = (tmpDir.path() / ".attrs.sh").string();
|
||||
writeFile(attrsSH, structuredAttrsRC);
|
||||
auto attrsJSON = (tmpDir.path() / ".attrs.json").string();
|
||||
writeFile(attrsJSON, json.dump());
|
||||
|
||||
env["NIX_ATTRS_SH_FILE"] = attrsSH;
|
||||
env["NIX_ATTRS_JSON_FILE"] = attrsJSON;
|
||||
}
|
||||
auto attrsSH = (tmpDir.path() / ".attrs.sh").string();
|
||||
writeFile(attrsSH, structuredAttrsRC);
|
||||
|
||||
env["NIX_ATTRS_SH_FILE"] = attrsSH;
|
||||
env["NIX_ATTRS_JSON_FILE"] = attrsJSON;
|
||||
}
|
||||
|
||||
/* Run a shell using the derivation's environment. For
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue