-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Introduce top-level structuredAttrs
field in JSON derivation format
#13349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce top-level structuredAttrs
field in JSON derivation format
#13349
Conversation
Makes the behavoral change of NixOS#13263 without the underlying refactor. Hopefully this clearly safe from a perf and GC perspective, and will make it easier to benchmark NixOS#13263.
23b9b16
to
f8c1ac9
Compare
@@ -1333,6 +1333,11 @@ nlohmann::json Derivation::toJSON(const StoreDirConfig & store) const | |||
res["args"] = args; | |||
res["env"] = env; | |||
|
|||
if (auto it = env.find("__json"); it != env.end()) { | |||
res["env"].erase("__json"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
res["env"].erase("__json"); | |
res["env"].erase(it); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't do this, because the iterator is for env
, but we're deleting in res["env"]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that when reading now too :). Only noticed after I got the compiler error.
auto envJson = valueAt(json, "env"); | ||
try { | ||
res.env = getStringMap(envJson); | ||
} catch (Error & e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it catch exceptions for env
specifically? (And not for any of the other attributes.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably should do this for all of these, to the extent that we care about nice errors. There might be a closure-based way to do this more tersely.
Motivation
Arguably progress on #9866
Context
Makes the behavoral change of #13263 without the underlying refactor. Hopefully this clearly safe from a perf and GC perspective, and will make it easier to benchmark #13263.
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.