-
-
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
Allow custom printing in nix repl #9380
Comments
Custom functions are more fragile when it comes to possibly cyclic structures. Those are detected by the current printing routine. To recover that functionality, the special show function could return values in a tree form with |
I think it's fine to keep it simple in this case: |
We should definitely add a cli flag to turn this off in case of any issues for better debugging. |
Is your feature request related to a problem? Please describe.
Sometimes there are attribute sets with a public interface but an internal structure, which when passed to
nix repl
currently print their internal structure by default. A good example is thelib.fileset
library:Related to that: Nixpkgs derivations are currently always printed as their
.drv
:When really, there's a lot more to the interface of a package than just its
.drv
, things likepassthru
,meta
,.override
attributes, etc. (notably not all attributes).Describe the solution you'd like
A special attribute like
__nixReplShowString
, which defines a__toString
-like function. When an attribute set with such an attribute gets passed to the REPL, instead of printing it recursively, it should just evaluate that attribute and print the resulting string:This should take precedence over the existing derivation printing, such that Nixpkgs can customise it more.
Describe alternatives you've considered
Additional context
This issue is sponsored by Antithesis ✨
Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: