Skip to content

Idea: trace transformer for debugging #50

@ratorx

Description

@ratorx

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions