nix-inspect icon indicating copy to clipboard operation
nix-inspect copied to clipboard

Show list items name along with their index

Open nicolas-goudry opened this issue 1 year ago • 4 comments

Basically, if a list is a:

  • list of strings
  • list of attrset with a name attribute

It would be great to get the string along with the item index.

I’m asking for this because currently in order to browse the environment.systemPackages I need to enter each item and scroll to the name attribute to know what it is.

Thanks!

nicolas-goudry avatar Apr 12 '24 15:04 nicolas-goudry

value previews for lists and attrsets are tricky, because Nix is lazy and just getting the type for one element can take a long time, which prevents us from evaluating anything else until its done. It might be possible to look at the options definitions instead of the config definition itself to get types and would be much faster, but even so expanding every package attrset might take a while.

bluskript avatar Apr 12 '24 15:04 bluskript

I see what you mean for the attrsets, but for the list of strings shouldn’t it be easy?

Regarding the attrset, would it be possible to lazy load the name attribute when the list is rendered to avoid blocking the view for too long?

nicolas-goudry avatar Apr 12 '24 16:04 nicolas-goudry

I think list of primitives could work, but for attrsets accessing any sub-attribute requires the parent attrset to be evaluated at least, unfortunately.

bluskript avatar Apr 12 '24 16:04 bluskript

What about an opt-in key to « force load attrset names »? This way, users are aware of the cost of this action but still get the feature.

nicolas-goudry avatar Apr 12 '24 16:04 nicolas-goudry