-
-
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
Add 'poison' context #10212
Add 'poison' context #10212
Conversation
0737401
to
319a862
Compare
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 like the idea, and I've linked my description/proposal issue in the PR description.
Besides the review comments, I have two points of attention
-
builtins.unsafeDiscardStringContext
: does it throw when it encounters the poison? I think it should (despite the unsafe qualifier) -
This adds a new cross-cutting responsibility to the evaluator and its callers. What can we do to make the
Value
and string context API safer? Perhaps the raw string value could be encapsulated behind getters that make the intent of the caller clear.- No context allowed
- Normal dependencies (store paths, outputs) allowed
- Diagnostics and dependencies allowed
You can still use them in derivations with some processing, albeit it's going to be much harder. |
Personally I think you should be allowed to deliberately shoot yourself in the foot, lest we accidentally create a need for alternative string context discarding functions. The point of this to me is to stop mistakes, rather than limit possible expression. |
Assuming "the functionality" is "pretty-printing values for debugging":
https://github.com/NixOS/nixpkgs/blob/4907e7a50c83b6214239d30a833f59493754eb48/nixos/modules/misc/documentation.nix#L54 In that case, you're stuck with the default
|
You could make string interpolation lazy, and then depending on how you use the resulting string, you could get the behavior you want. So I'm not sure this complexity is worth it, but I don't think it would be very complex to implement. |
We could make it accept a "data-only" DSL. Maybe not go overboard with tons of functionality like #7795, but maybe implement what this issue calls MVP. Not sure if we want to force such a representation on library authors, so maybe there's a case for both solutions to exist eventually. |
This can be added to strings to prevent them from being used in derivations. This lets us implement "unstable" functions without fear!
319a862
to
f1737d0
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-03-11-nix-team-meeting-132/42960/1 |
This can be added to strings to prevent them from being used in derivations. This lets us implement "unstable" functions without fear!
Motivated by #10206.
Priorities and Process
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.