Announcing nix-query-tree-viewer - GUI viewer for the output of `nix store --query --tree`

I recently released nix-query-tree-viewer. It is a GTK-based GUI for interactively exploring the output of nix-store --query --tree.

Here is a screenshot:


nix-store --query --tree can be very helpful to figure out the transitive dependencies of a derivation, but the output can be overwhelming for many complicated derivations.

Here’s an example of what the output of nix-store --query --tree looks like:

$ nix-store --query --tree /nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0
/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0
+---/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27
|   +---/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27 [...]
+---/nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23
|   +---/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27 [...]
|   +---/nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23 [...]
+---/nix/store/hlnxw4k6931bachvg5sv0cyaissimswb-gcc-7.4.0-lib
|   +---/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27 [...]
|   +---/nix/store/hlnxw4k6931bachvg5sv0cyaissimswb-gcc-7.4.0-lib [...]
+---/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin
|   +---/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27 [...]
...

The screenshot above shows this same output in nix-query-tree-viewer.

See the README.md for usage instructions.

In a couple days I will send a PR adding this to nixpkgs.

This is my first non-trivial Rust project, so I’d be really happy to get any feedback on the code as well.

18 Likes

I’ve sent a PR adding this to nixpkgs:

https://github.com/NixOS/nixpkgs/pull/80771

how easy was it to get started with rust? (I also have a background in haskell)

1 Like

Coming from Haskell, I felt that it was pretty easy to get started with Rust.

From what I’ve seen so far, people new to Rust have trouble with the following things:

  1. Traits (typeclasses in Haskell)
  2. Lifetimes
  3. Ownership, moving, borrowing, references, etc

Traits are pretty much a subset of the functionality of Haskell’s typeclasses, so they shouldn’t give you much of a problem.

Lifetimes aren’t a thing in Haskell, so they might give you a little more trouble. However, I didn’t have much trouble with them after reading the section in the Rust book about them. I think it is because the rules governing lifetimes somewhat resemble parametric polymorphism in Haskell. (Although I should say that I havent done a huge amount of Rust, so it is possible there are some really tricky things I haven’t stumbled on yet.)

The thing I had the most trouble with was ownership, moving, references, and borrowing.

I feel like I had to write maybe 1500 lines of Rust to have a clear idea how this worked, and then another 1500 to actually start to feel comfortable.

However, I still don’t feel like I have a perfect understanding of how to write the most polymorphic code in terms of ownership. That is to say, how to write functions that can be called from the most places.

The nicest thing I found about Rust is the community. Having an enthusiastic community, and backing by a company make a world of difference. I really can’t overstate how nice this is.


Here are the biggest things I dislike about rust coming from Haskell:

  1. No polymorphism over higher-kinded-types. This isn’t a huge deal if you’re just writing applications, but it sucks if you’re writing a library, or trying to creat some types of abstraction. Not having functor/applicative/monad/foldable/traversable is really terrible.

    In my opinion, this is the number one reason I’d continue to write any “serious” projects in Haskell.

  2. (I was going to add a second thing here, but nothing is coming to mind. I’ll update this list if I think of anything)

2 Likes

I have missed higher-kinded types on several occasions, but I think there is also a large benefit. If you have to use another Rust library, they are usually pretty easy to understand, because the Rust ecosystem does not suffer from abstractionitis as much as the Haskell ecosystem. This was the primary reason I stopped using Haskell after two years or so – there were a lot of abstractions to learn, every library used a different set of abstractions (I was using Haskell at a time that there were several competing ‘lens’ implementations), and abstractions were changing every few months.

If there is one thing I would take from Haskell, it would be more pedestrian: a good REPL. Unfortunately, Rust does not really have the lightweight syntax necessary to make it amendable for REPLs. There is a Jupyter kernel though.

1 Like

language extensions were also a big source of complexity for me when I was trying to learn. I would look at some of the more “advanced” codebases which would have 12+ language extensions turned on, and it’s a completely different language.

I agree with snoyman with his manifesto Boring Haskell Manifesto

3 Likes

Thanks, I hadn’t seen that, but it is spot-on. Haskell is both a great research vehicle and a great production language, but the mixing of both purposes sometimes make things hard on the production side. I look forward to see what comes from his efforts!

1 Like

I think this is a good point. Haskell gives you almost unlimited freedom for abstraction, but that freedom definitely comes with a cost. It’s annoying when you want to reach for that type of abstraction and it doesn’t exist, but it definitely makes the language/ecosystem harder to learn.