-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
[RFC 0110] Add "inherit-as-list" syntax construct to the Nix language #110
base: master
Are you sure you want to change the base?
Conversation
Initial MVP implementation for [RFC 110](NixOS/rfcs#110)
Initial MVP implementation for [RFC 110](NixOS/rfcs#110)
Definitely in favor of this. |
They are highlighted incorrectly as they are not currently valid Nix code
I can imagine many cases where you care about the order, not to mention that the order of build inputs also affects the final derivation.
I think it's best to have the order be defined and duplicates allowed.
|
Can you list some? Maybe I'm just drawing a blank here but I feel like this is unusual (so should stick out from the typical case), and this is what most of my preference for the current form hinges on. E.g.
I actually like the attr sorting because of this, it means that you can reorder the attrnames in either type of inherit expression without changing the resulting value, so rebuilds don't trigger. Lastly, the
are all meaningful and useful in their own right. |
Before: ``` [ inherit (attrs) a b c; ] := builtins.attrValues { inherit (attrs) a b c; } ``` After: ``` [ inherit (attrs) a b c; ] := [ attrs.a attrs.b attrs.c ]; ``` The previous desugaring has some potentially nice properties such as non-significant ordering and no-duplicate enforcement, but was ultimately deemed unintuitive and too surprising in practical use.
Thanks all for your feedback! I've updated the RFC to use the simplified order-preserving desugaring. |
Let's say the order is random. Each time you evaluate a derivation that uses the syntax, you would get a different derivation. |
The thing is, as soon as you derive e.g. a search-path from a list of let's say derivations, the order indeed matters. If e.g. Other than that I'm not very happy with reusing Finally, while I agree that All in all, I'm rather skeptical about this language change. |
> I can imagine many cases where you care about the order
Can you list some? Maybe I'm just drawing a blank here but I feel like this is unusual (so should stick out from the typical case), and this is what most of my preference for the current form hinges on. E.g.
One place where order matters in an annoying way is building something statically and something dynamically in the same derivation (you need to get the order of `glibc` and `glibc.static` right…)
There are probably more cases like that, so I am skeptical about even a fixed order independent of the order in the invocation, let alone the annoyance of having randomly permuted search paths change the hash even if the difference is immaterial.
|
By "unspecified", I meant "not explicitly specified by the user", not "unspecified by the language". The attrValues desugaring would sort on attrnames so the as-list ordering would be stable and documented.
Agreed, I think the keyword somewhat makes sense when using the attrValues-based desugaring, but less so if the values are simply plucked from the list in order. The keyword reuse is really just to avoid having to add a new one to the language, and
IMO this simple scenario is a perfect illustration. We all know exactly what is meant by this expression - and yet the semantics are not so simple:
This is a lot of "spooky action at a distance" for such a simple intent. I think a replacement without these footguns is sorely needed. |
Bravo for this RFC. I just wonder if adding a new keyword to Nix would be all that bad really? Wouldn't it have more or less the same implication; i.e. it doesn't break existing code but new code using the new syntax wouldn't work with older versions of Nix? If we allow a new keyword, we can maybe come up with something a bit more clear. With a new keyword If we wanted to add regular values after a from expression, we chould simply use a
Could you please clarify this, perhaps I am misunderstanding but it seems like you are saying |
The issue with a new keyword is IIRC that variables named like it will usually cause syntax errors (though I don't know the lexer well enough to say whether this is an inevitable consequence or just a side-effect). To demonstrate what I'm talking about:
But if someone who knows the lexer well-enough to falsify this assumption (e.g. @edolstra ?), I'd be totally in favor of a new keyword if such a change is supposed to be made.
Nope it doesn't have a special meaning. What I was trying to say is that I'm used to interpret a |
I guess worst case for a new keyword then would be that it requires manual intervention in the case of a colliding variable name, which doesn't sound horrible if we choose a keyword that is unlikely to be often used as a variable. I see your point about having two delimiters inside a list. Maybe we could just remove the need for a Even if we stick with |
We'd essentially throw away the ability to instantiate any old Nix expression. Correct me if I'm wrong, but IIRC that's why e.g. the URL syntax (
If we do this, we should abolish |
Sorry if I've missed this as I only skimmed the comments, but is a normal function really that bad? I had a look in "alternatives", but I don't think that's exhaustive. The alternative that comes to my mind is: [ attrs.x attrs.y attrs.z ] becomes select [ "x" "y" "z" ] attrs It's a tiny bit more verbose than [ inherit (attrs) x y z ] For multiple inherits clauses, I would probably just build a list-of-lists and then concat: lib.concat [
(select [ "x" "y" ] foo)
(select [ "u" "v" ] bar)
] |
@ocharles TBH that's probably the best solution. The issue is then getting people to do this, i.e. social. |
Well, it also highlights wrong, I guess (these strings are not data but literal variable names) |
The order of elements in the new
If the order was undefined/unstable, drv’s wouldn’t be deterministic anymore. I want to argue against the first (arbitrary ordering), since not much is gained and people will start to depend on (that is: abuse) an implementation detail like this. On a more general note, I’m 💯 👍 on this change, it’s simple enough, will make the language more symmetrical, and we can finally start deprecating |
Why is a language change is required to get people to stop using |
@ocharles because (And I am pretty sure |
Linked content has moved to recipes/best-practices
@r-burns We discussed the RFC today in the Nix maintainers meeting. The proposal seems to optimise for a particular use of In any case, we'd err towards not changing the language if in doubt unless there are extraordinarily compelling reasons, both to keep complexity and the learning curve in check. Complete discussion
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-06-26-nix-team-meeting-minutes-66/29650/1 |
I'm not sure how to continue with this as I don't really see how to come up with more pro/cons for this idea. Does someone have a good path to take for this RFC? Should this RFC be closed? |
We may want to get input from @sternenseemann, @tazjin or @amjoseph-nixpkgs on whether this specific approach is viable. I can imagine it can be continued to elaborate on the You can continue piling up considerations and that may change the conclusion, nothing seems wrong with that. If you feel like taking a new direction mandates a different proposal, that should be fine as well. In any case, for any such substantial change to the language to get buy-in, we'd need agreement by implementers (currently Nix and Tvix) and large-scale users (Nixpkgs maintainers), who will have most experience with what to look out for. |
Visual Basic forces But unfortunately this is not possible for Nix, because
Here
|
There is a long discussion (at least 1h30) about I originally proposed a But in the end the only thing I care about is that we can fully deprecate So I think this RFC needs to include that |
I slightly disagree. I do agree that we do need a plan for how to deprecate That being said I don't think that it is good to add these feature piecemeal. I think we need to understand the whole replacement before we start moving on any part of it to ensure consistency while avoiding gaps and overlaps from different features. |
After discussing with @r-burns we are going to mark this RFC as a draft. It is clear that before moving forward with this proposal we need more understanding and design about a post- Others are of course welcome to pick up this idea and run with it if they have the resources to fit together the full story of |
If somebody has the time and energy, I think like something like #137 would be a more impactful change to work towards, which will also benefit any potential |
#137 is not really that relevant for reduction of |
@7c6f434c This RFC here is not specific to Nixpkgs, it proposes to introduce a new Nix language feature with the intention of getting closer to the deprecation of |
If And the question for this is not about getting Nix to deprecate it globally, but to have enough replacements for frequent Nixpkgs uses and confine the rest. #137 is not relevant to the parts that actually matter for the motivation here — providing alternatives to with for the cases where it's just not worth it. |
* Expressions reliant on the new syntax will be incompatible with | ||
Nix versions prior to the introduction of this feature. | ||
|
||
# Alternatives |
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.
Was a new keyword suggested?
I'm chiming in to say that I really wish this existed. |
If someone implemented this the RFC would probably have a better chance of being accepted. It shouldn't be too hard. Or maybe someone already has implemented it? |
@L-as Please note that the parser is currently being re-written by pennae, but I'm not sure how hard it would be to add this. |
Also, there were some comments from Nix team about not wanting to add new syntax before any kind of policy to removing it has been finalised… |
Rendered