-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Should path values be deprecated? #7338
Comments
While there are a few warts with path values, I don't see how that justifies removing them. How would you distinguish between the derivation attributes
vs
And if the idea is to keep the path syntax but not path values: that doesn't work for lazy trees, where
We're not going to prefix |
I agree with @edolstra's answer and it is a sufficient answer to the question as posed, so I won't go into all that was said, but I think a few underlying concerns could still be addressed.
I couldn't easily find the section of the manual that explains path interpolation / antiquotation. Actionable:
Operating on the logical model keeps the path logic simple. Both the logical and physical model are valid, and either choice would lead to confusion. I do not believe that a switch is warranted for this reason alone, but also this would be even more breaking, because currently path values can also be used for manipulating paths that aren't relative to the evaluating system's filesystem root. By assuming that they are, we're introducing a perhaps rare, but very surprising impurity in such code. Actionable:
Actionable:
Builtins do not work with relative paths, because they don't have an ambient base directory to work from. Path values bridge the gap between the relative path syntax and the builtins. To keep supporting this is in line with Eelco's answer. Finally, making such a breaking change breaks its ability to evaluate older expressions, which would seriously impact Nix's applicability in a number of valuable areas. |
@roberth do you mean that it's missing the |
@fricklerhandwerk Yes. Edited. |
@roberth This #7278 adds a complete section on string interpolation, which also mentions copying paths to the store (which has been there for a while actually). I hope to find time to eventually rework that by reusable including text sections in multiple locations, because right now that information only lives in one place but should actually be available both in the data type references as well as the string interpolation section. But that would be too much of a change at once. |
That's a good improvement, but it's still only from the string perspective. We'll also need a section that focuses on path values. |
@roberth, I also opened #7498 to account for operator behavior. Before I proceed to opening an entire section just on paths, the glossary, data types section, and possibly architecture chapter need some more work. Then we can just refer to existing explanations of terms or mechanisms, and focus on what makes paths special in Nix. |
Don't remove path-types, but do make the concepts consistent. In particular, I would recommend that the current function of We almost have a consistent rule in the nix language that path-types are resolved at eval time and strings containing paths are resolved at run time (or sometimes build time). If the language was consistent in this, and the rule was clearly stated in documentation and introductions to the language, I think newbies wouldn't have too much trouble with the concept, despite its uniqueness. It's something that's obviously very valuable for the nix language's domain of use. |
The Nix language has path expressions which evaluate to path values. I believe it might be good to deprecate path values and eventually make path expressions return string values instead.
Reasons why path values aren't great:
builtins.toString
behave the same #7327:"${some/path}"
imports the path into the store"${toString some/path}"
doesn't import it into the store..
path components get normalised for no good reason (which can be wrong if symlinks are involved, which Nix doesn't check for):/
getting normalised, see also Overload/
to mean path append; alternative topath + "/" + "foo"
footgun #7301:Meanwhile, there's essentially no good use cases for path values:
builtins.path
can be used to explicitly import a path into the store, which would make it much more obvious when it happens and it can't happen accidentally...
not getting normalised awayIgnoring deprecation for now, I think ideally path expressions should return string values instead, so like an implicit
toString
. This then requires people to be very explicit about what gets imported into the store, either usingbuiltins.path
or some library function built on top (likelib.cleanSource
).See also #7335 and NixOS/nixpkgs#200718, ping @roberth @fricklerhandwerk
The text was updated successfully, but these errors were encountered: