aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.hh
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2013-07-15 15:53:14 -0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-07-31 11:48:39 +0200
commit20866a7031ca823055a221653b77986faa167329 (patch)
treed07010bb8407cfd97467e76098d5f292af1906e0 /src/libexpr/eval.hh
parent70e68e0ec604124bb248ea4d064307bbf96e7932 (diff)
Delay evaulation of `with` attrs until a variable lookup needs them
Evaluation of attribute sets is strict in the attribute names, which means immediate evaluation of `with` attribute sets rules out some potentially interesting use cases (e.g. where the attribute names of one set depend in some way on another but we want to bring those names into scope for some values in the second set). The major example of this is overridable self-referential package sets (e.g. all-packages.nix). With immediate `with` evaluation, the only options for such sets are to either make them non-recursive and explicitly use the name of the overridden set in non-overridden one every time you want to reference another package, or make the set recursive and use the `__overrides` hack. As shown in the test case that comes with this commit, though, delayed `with` evaluation allows a nicer third alternative. Signed-off-by: Shea Levy <shea@shealevy.com>
Diffstat (limited to 'src/libexpr/eval.hh')
-rw-r--r--src/libexpr/eval.hh1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index a57efa08f..0e4ad3db2 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -53,6 +53,7 @@ struct Env
{
Env * up;
unsigned int prevWith; // nr of levels up to next `with' environment
+ Expr * withAttrs;
Value * values[0];
};