nickel
nickel copied to clipboard
Provenance, aka “where did this attribute come from”
One use-case for nixpkgs overlays I just had: We define an overlay of pkgs where we override and add some packages. I just went directly to nixpkgs to see the definition of a package, totally missing that we had overridden it locally.
It would be nice if there was a “stack trace” of sorts that can show how attributes “came to be”, aka where they were added/changed. I don’t know how feasable that is.
So, for example, file A defines:
{ foo = 32; }
file B says:
(import A) & { foo = self.foo + 10 }
And if I tell nickel: “show me the provenance of foo in B”:
A.ncl:1 foo = 32
B.ncl:1 foo = 42
or somesuch.
This uses the proposed self feature to do self-recursion with merges, but of course could be adapted to other ways of recursion.
This wouldn't be hard to do I think, using metavalues to store this information, without much overhead. Then the query sub-command could show this information along the value.
(import A) & { foo = self.foo + 10 }
As a side note, I don't see a way of interpreting this other than an infinite loop, but I get what you meant.
Ah yes, self would refer to the foo I just define in this case, so I
guess it would have to be super or something?
On Fri, Dec 4, 2020 at 1:41 PM Yann Hamdaoui [email protected] wrote:
This wouldn't be hard to do I think, using metavalues to store this information, without much overhead. Then the query sub-command could show this information along the value.
(import A) & { foo = self.foo + 10 }
As a side note, I don't see a way of interpreting this other than an infinite loop, but I get what you meant.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tweag/nickel/issues/235#issuecomment-738763040, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYB5ZRIMY3P67RAWPAY2RLSTDKHBANCNFSM4ULRIACA .