Skip to content

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

Merged
merged 1 commit into from
Jun 18, 2025

Conversation

Ericson2314
Copy link
Member

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.

@Ericson2314 Ericson2314 requested a review from edolstra as a code owner June 11, 2025 19:45
@github-actions github-actions bot added documentation with-tests Issues related to testing. PRs with tests have some priority labels Jun 11, 2025
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.
@@ -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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
res["env"].erase("__json");
res["env"].erase(it);

Copy link
Member Author

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"].

Copy link
Member Author

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) {
Copy link
Member

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.)

Copy link
Member Author

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.

@Ericson2314 Ericson2314 merged commit d254c84 into NixOS:master Jun 18, 2025
12 checks passed
@Ericson2314 Ericson2314 deleted the structured-attrs-json branch June 18, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation with-tests Issues related to testing. PRs with tests have some priority
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants