Skip to content
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

Feature request: graphviz export #59

Closed
SomeoneSerge opened this issue May 24, 2023 · 2 comments · Fixed by #81
Closed

Feature request: graphviz export #59

SomeoneSerge opened this issue May 24, 2023 · 2 comments · Fixed by #81
Labels
enhancement New feature or request

Comments

@SomeoneSerge
Copy link

Hi! I don't know if nix-tree would be an appropriate place for this kind of a "generic" feature, but I think it'd be lovely to be able to do something like this:

❯ nix shell nixpkgs#nix-du nixpkgs#xdot
❯ nix-tree --derivation .#nixosConfigurations.$(hostname).config.system.build.toplevel --graphviz | xdot -i

...and nix-tree already provides the convenient interface of "installables" for the task of enumerating the full closure

Just to give an idea of what output I'm looking for, here's a screenshot for

nix-du -s=500MB | xdot -

image

@utdemir
Copy link
Owner

utdemir commented May 24, 2023

Thanks for the issue! I agree, this is a useful feature.

If I understand correctly, the difference of your request and:

nix-store -q --graph /nix/store/na56nh4y1m0s1z5rgki99fj7imj433ld-nix-tree-0.3.1

is that, you can pass a flake reference, right?

If so, it does feel like it is more suitable to:

  • Either tools like nix-visualize
  • Or adding a --graphviz parameter to a flake-aware command like nix store ls or nix path-info.

But on the other hand it really wouldn't be hard to add it to nix-tree, as we have all the dependency graph right there; we just need to print it. I gave it a go on ud/dot branch, can you check it out if it works for you?

nix run 'github:utdemir/nix-tree?ref=ud/dot' -- --derivation .#nixosConfigurations.$(hostname).config.system.build.toplevel --dot | xdot -i

Currently it prints out a simple dot file without any styling, formatting, and it doesn't look very pretty to be honest:

example

So, I am happy to merge it as-is, or let me know if you have any other suggestions to make it better :).

@utdemir utdemir added the enhancement New feature or request label Dec 13, 2023
@SomeoneSerge
Copy link
Author

Sorry about disappearing. Yes I think --dot and passing the "flake references" through is good. The graphviz format can be parsed by external tools (e.g. python's networkx), and doesn't seem to include any data other than what nix-tree already deals with. Wouldn't make sense to do more special-casing in nix-tree, and definitely not in the nix repo (nix path-info ... --dot doesn't sound unreasonable, but the nix cli is already overloaded).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants