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

Idea: trace transformer for debugging #50

Open
ratorx opened this issue Aug 22, 2024 · 1 comment
Open

Idea: trace transformer for debugging #50

ratorx opened this issue Aug 22, 2024 · 1 comment

Comments

@ratorx
Copy link

ratorx commented Aug 22, 2024

Not an issue, but a possibly useful transformer that might be nice to have.

I've been playing around with haumea and whilst trying to debug some dependencies had the idea for a tracing dependencies by using the following transformer:

cursor: mod: builtins.mapAttrs (n: v: builtins.trace "eval ${lib.strings.concatStringsSep "." (cursor ++ [n])}" v) mod;

This will produce a haumea tree that will output evaluation traces for all module accesses, which you could use in conjunction with nix repl to easily figure out all the dependencies of an attribute:

So if you had a haumea tree like (not actually evaluable, just shorthand):

foo = {
  bar = 5;
  baz = {
    something = root.foo.bar + 1;
  } 
}

Running nix repl -f haumea_tree.nix foo.baz.something would produce the trace of:

trace: eval foo
trace: eval foo.baz
trace: eval foo.baz.something
trace: eval foo
trace: eval foo.bar
@ratorx ratorx changed the title Trace transformer for debugging Idea: trace transformer for debugging Aug 22, 2024
@gyaruwizard
Copy link

gyaruwizard commented Oct 7, 2024

Reasonable suggestion. It's even more powerful due to its invariance. This means that it can be used to visualize how other transformers are consuming modules down the pipe:

transformers = with haumea.lib.transformers; [ trace liftDefault trace prependUnderscore trace ];

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

No branches or pull requests

2 participants