nix-tree
nix-tree copied to clipboard
Feature request: show only tree that depends on regex
I'd like to be able to see the packages that depend on e.g. Perl, and their parents.
Ideally, you'd be able to search for "perl", and then the tree makes it obvious which packages transitively and which directly depend on it. Perhaps just don't show the ones that don't depend?
Here's how I'd do this right now:
nix-treehas already has a search functionality (shortcuts), so I'd use it to search the store path I'm looking for. But it's just a case-insensitive plain text search, so no fancy expressions there.- Store paths directly depend on it are on the bottom status bar, called
Immediate Parents. nix-treealso has awhy-dependsmode (shortcutw), and you can see the store path transitively depend on it there. You can even navigate to one of those, highlighting the part there on the main panes.
Does that work for you?
Otherwise, we can have something like a "focus mode", where a shortcut marks the current selected store path "focused"; then only its ancestors and descendents will be visible. Then probably pressing it again will remove the focus. It kind of make sense to me, but I'm afraid of adding too many confusing functionality to it. But please let me know if you prefer something like that, or if you have another suggestion.
Ok, plain search is fine, but I'd indeed like to have this focus mode 🙂 It's just really helpful to see things in a tree structure.
Okay, I think this is a good idea. The implementation is going to be a bit tricky, because it affects many places. So I'll probably only start to look at it the next weekend.
So, here's some bad news. I think the trivial way to implement this (hide everything which is not either an ancestor or descendent of the "focused" store path) won't be as nice.
Because, imagine having the focused path at the middle pane. You'd expect the left pane to contain the parents of that path, but the above approach does not do that (it'll only show the children of the previously selected grandparent).
I think the ideal would be flipping the dependency graph and apply the mechanism for the right panes to the left pane; so having all parents of the focused path on the left, and their parents on the left of the left and so on (it's hard to explain, sorry).
However, it is tricky to implement. Also it introduces a lot of design issues (what will the sizes mean in that case, how will why-depends/search will work). So, I don't think I'll be able to spend necessary time on it soon enough. However I will keep considering it and maybe we'll figure out a nice way to do this.
Ok, you know best :) although I don't understand the middle pane explanation. Won't you only see connected parts of the graph?
So, let's think about this graph:

And say, you navigated to node e through root -> a -> b -> e. Your panes would look like this in the current state of nix-tree.
------------------
| [b] | [e] | f |
------------------
But, this does not mean that b is the only parent of e, it merely means that the previous pane contained only b.
I think, if you were to now use the hypothetical "focus" feature on e, you'd prefer to see something like:
-----------------
| [b] | [e] | f |
| c | | |
| d | | |
-----------------
This'd make it easier to see which packages depend on e, which I think is closer to what you want. However, implementing this is tricky (mostly UX-wise).