-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Nested attribute merging may or may not work as intended #11268
Comments
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-08-12-nix-team-meeting-minutes-168/50561/1 |
Discussed during aforementioned Nix maintainers meeting: The code that handles these syntax combinations is fairly complex and would probably need to be refactored in order to support this properly. If supporting this properly proves infeasible, we might deprecate some variations, but not remove it, because they've been supported for around 2 years.
These restrictions are not intentional. It used to be that explicit attrsets in repeated attrs could not be merged at all. ~2 years ago we've started supporting that, but apparently the support is not complete. Perhaps you could document it, but add a caveat that not all combinations are currently supported. Would you be interested in improving support for these cases? |
I'm interested in taking a stab at it, if the refactoring doesn't prove to be too difficult! |
WRT #9020, I assume that you'll want me to keep monstrosities like this working? nix-repl> { a = rec { b = 1; }; a.c = b + 1; }.a.c
2 |
Describe the bug
I would like to be able to say the following:
a.b.c = 1;
is equivalent toa = { b = { c = 1; }; };
rec
keyword, maybe)These two simple rules would explain both the common
and the less-common
without appealing to additional rules.
This unfortunately fails to hold for deeper attribute paths:
I don't know if this is a bug (if so, it should be fixable without any breaking changes) or if this is an as-intended aspect of the language that I haven't found a succinct way to describe yet.
Other remarkable comparisons:
Steps To Reproduce
Try to evaluate
Expected behavior
Same as
{ a.b.c = 1; a.b.d = 2; }
.nix-env --version
outputnix-env (Nix) 2.24.0
Additional context
Knowing whether this is a bug or not is a minor blocker for me writing up a specification of how bindings work as part of #10970. It's fine if it's a bug that hasn't been fixed yet; that can be noted in the documentation. It's also fine if this is how things are supposed to work; I can write the more complicated specification.
Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: