mirror of
https://github.com/NixOS/nix.git
synced 2025-12-11 03:21:03 +01:00
Store StructuredAttrs directly in Derivation
Instead of parsing a structured attrs at some later point, we parsed it right away when parsing the A-Term format, and likewise serialize it to `__json = <JSON dump>` when serializing a derivation to A-Term. The JSON format can directly contain the JSON structured attrs without so encoding it, so we just do that.
This commit is contained in:
parent
b062730665
commit
8652b6b417
16 changed files with 177 additions and 109 deletions
|
|
@ -32,12 +32,9 @@ DerivationBuildingGoal::DerivationBuildingGoal(
|
|||
{
|
||||
drv = std::make_unique<Derivation>(drv_);
|
||||
|
||||
if (auto parsedOpt = StructuredAttrs::tryParse(drv->env)) {
|
||||
parsedDrv = std::make_unique<StructuredAttrs>(*parsedOpt);
|
||||
}
|
||||
try {
|
||||
drvOptions =
|
||||
std::make_unique<DerivationOptions>(DerivationOptions::fromStructuredAttrs(drv->env, parsedDrv.get()));
|
||||
std::make_unique<DerivationOptions>(DerivationOptions::fromStructuredAttrs(drv->env, drv->structuredAttrs));
|
||||
} catch (Error & e) {
|
||||
e.addTrace({}, "while parsing derivation '%s'", worker.store.printStorePath(drvPath));
|
||||
throw;
|
||||
|
|
@ -661,7 +658,6 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
|
|||
buildMode,
|
||||
buildResult,
|
||||
*drv,
|
||||
parsedDrv.get(),
|
||||
*drvOptions,
|
||||
inputPaths,
|
||||
initialOutputs,
|
||||
|
|
|
|||
|
|
@ -63,9 +63,8 @@ Goal::Co DerivationGoal::haveDerivation()
|
|||
trace("have derivation");
|
||||
|
||||
auto drvOptions = [&]() -> DerivationOptions {
|
||||
auto parsedOpt = StructuredAttrs::tryParse(drv->env);
|
||||
try {
|
||||
return DerivationOptions::fromStructuredAttrs(drv->env, parsedOpt ? &*parsedOpt : nullptr);
|
||||
return DerivationOptions::fromStructuredAttrs(drv->env, drv->structuredAttrs);
|
||||
} catch (Error & e) {
|
||||
e.addTrace({}, "while parsing derivation '%s'", worker.store.printStorePath(drvPath));
|
||||
throw;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue