66
77namespace nix {
88
9- ParsedDerivation::ParsedDerivation (BasicDerivation & drv )
10- : drv(drv )
9+ ParsedDerivation::ParsedDerivation (const StringPairs & env )
10+ : env(env )
1111{
1212 /* Parse the __json attribute, if any. */
13- auto jsonAttr = drv. env .find (" __json" );
14- if (jsonAttr != drv. env .end ()) {
13+ auto jsonAttr = env.find (" __json" );
14+ if (jsonAttr != env.end ()) {
1515 try {
1616 structuredAttrs = std::make_unique<nlohmann::json>(nlohmann::json::parse (jsonAttr->second ));
1717 } catch (std::exception & e) {
@@ -34,8 +34,8 @@ std::optional<std::string> ParsedDerivation::getStringAttr(const std::string & n
3434 return i->get <std::string>();
3535 }
3636 } else {
37- auto i = drv. env .find (name);
38- if (i == drv. env .end ())
37+ auto i = env.find (name);
38+ if (i == env.end ())
3939 return {};
4040 else
4141 return i->second ;
@@ -54,8 +54,8 @@ bool ParsedDerivation::getBoolAttr(const std::string & name, bool def) const
5454 return i->get <bool >();
5555 }
5656 } else {
57- auto i = drv. env .find (name);
58- if (i == drv. env .end ())
57+ auto i = env.find (name);
58+ if (i == env.end ())
5959 return def;
6060 else
6161 return i->second == " 1" ;
@@ -80,8 +80,8 @@ std::optional<Strings> ParsedDerivation::getStringsAttr(const std::string & name
8080 return res;
8181 }
8282 } else {
83- auto i = drv. env .find (name);
84- if (i == drv. env .end ())
83+ auto i = env.find (name);
84+ if (i == env.end ())
8585 return {};
8686 else
8787 return tokenizeString<Strings>(i->second );
@@ -155,17 +155,18 @@ static nlohmann::json pathInfoToJSON(
155155std::optional<nlohmann::json> ParsedDerivation::prepareStructuredAttrs (
156156 Store & store,
157157 const DerivationOptions & drvOptions,
158- const StorePathSet & inputPaths)
158+ const StorePathSet & inputPaths,
159+ const DerivationOutputs & outputs)
159160{
160161 if (!structuredAttrs) return std::nullopt ;
161162
162163 auto json = *structuredAttrs;
163164
164165 /* Add an "outputs" object containing the output paths. */
165- nlohmann::json outputs ;
166- for (auto & i : drv. outputs )
167- outputs [i.first ] = hashPlaceholder (i.first );
168- json[" outputs" ] = outputs ;
166+ nlohmann::json outputsJson ;
167+ for (auto & i : outputs)
168+ outputsJson [i.first ] = hashPlaceholder (i.first );
169+ json[" outputs" ] = std::move (outputsJson) ;
169170
170171 /* Handle exportReferencesGraph. */
171172 for (auto & [key, storePaths] : drvOptions.exportReferencesGraph ) {
0 commit comments