You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 the lib.fileset library:
When really, there's a lot more to the interface of a package than just its .drv, things like passthru, 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:
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 value attributes for automatic deduplication.
Other reasons why returning structured data is nice, is that Nix could implement pretty printing, layouts, more semantically useful messages, etc.
I think it's fine to keep it simple in this case: __nixReplShowString must return a string, which is directly printed. I don't think we have a need for anything more powerful for now. And if we do in the future we could add another special more general special attribute for it.
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: