about summary refs log tree commit diff
path: root/src/libexpr/eval.hh
AgeCommit message (Collapse)AuthorFilesLines
2015-03-19 Fix Boehm API violationEelco Dolstra1-0/+4
We were calling GC_INIT() after doing an allocation (in the baseEnv construction), which is not allowed.
2015-02-23 Add restricted evaluation modeEelco Dolstra1-0/+6
If ‘--option restrict-eval true’ is given, the evaluator will throw an exception if an attempt is made to access any file outside of the Nix search path. This is primarily intended for Hydra, where we don't want people doing ‘builtins.readFile ~/.ssh/id_dsa’ or stuff like that.
2015-01-15 Fix assertion failure in nix-envEelco Dolstra1-3/+5
$ nix-env -f ~/Dev/nixops/ -iA foo nix-env: src/libexpr/eval.hh:57: void nix::Bindings::push_back(const nix::Attr&): Assertion `size_ < capacity' failed. Aborted
2015-01-07 Show position info for failing <...> lookupsEelco Dolstra1-1/+1
2014-12-12 Remove canary stuffEelco Dolstra1-8/+0
2014-11-25 forceString(): Accept pos argumentEelco Dolstra1-1/+1
2014-11-15 Add functors (callable attribute sets).Shea Levy1-1/+1
With this, attribute sets with a `__functor` attribute can be applied just like normal functions. This can be used to attach arbitrary metadata to a function without callers needing to treat it specially.
2014-10-20 Fix build on gcc < 4.7Shea Levy1-0/+3
2014-10-17 Export realiseContext in libnixexprShea Levy1-0/+8
Useful for importNative plugins
2014-09-24 Bindings: Remove copy constructorEelco Dolstra1-2/+3
2014-09-22 Rename strictForceValue -> forceValueDeepEelco Dolstra1-1/+1
2014-09-22 Add a function ‘valueSize’Eelco Dolstra1-2/+3
It returns the size of value, including all other values and environments reachable from it. It is intended for debugging memory consumption issues.
2014-09-19 Inline Bindings::find()Eelco Dolstra1-1/+8
2014-09-19 Store Attrs inside BindingsEelco Dolstra1-24/+48
This prevents a double allocation per attribute set.
2014-09-17 Add some instrumentation for debugging GC leaksEelco Dolstra1-0/+8
2014-08-21 Fix a segfault in ‘nix-env -qa’Eelco Dolstra1-1/+1
This was triggered by 47e185847e729d49e6aa376e8299fd66ef834a0a, which turned globals.state into a pointer.
2014-05-26 Make the Nix search path declarativeEelco Dolstra1-1/+4
Nix search path lookups like <nixpkgs> are now desugared to ‘findFile nixPath <nixpkgs>’, where ‘findFile’ is a new primop. Thus you can override the search path simply by saying let nixPath = [ { prefix = "nixpkgs"; path = "/my-nixpkgs"; } ]; in ... <nixpkgs> ... In conjunction with ‘scopedImport’ (commit c273c15cb13bb86420dda1e5341a4e19517532b5), the Nix search path can be propagated across imports, e.g. let overrides = { nixPath = [ ... ] ++ builtins.nixPath; import = fn: scopedImport overrides fn; scopedImport = attrs: fn: scopedImport (overrides // attrs) fn; builtins = builtins // overrides; }; in scopedImport overrides ./nixos
2014-05-26 Ensure that -I flags get included in nixPathEelco Dolstra1-2/+1
Also fixes #261.
2014-05-26 Add primop ‘scopedImport’Eelco Dolstra1-0/+1
‘scopedImport’ works like ‘import’, except that it takes a set of attributes to be added to the lexical scope of the expression, essentially extending or overriding the builtin variables. For instance, the expression scopedImport { x = 1; } ./foo.nix where foo.nix contains ‘x’, will evaluate to 1. This has a few applications: * It allows getting rid of function argument specifications in package expressions. For instance, a package expression like: { stdenv, fetchurl, libfoo }: stdenv.mkDerivation { ... buildInputs = [ libfoo ]; } can now we written as just stdenv.mkDerivation { ... buildInputs = [ libfoo ]; } and imported in all-packages.nix as: bar = scopedImport pkgs ./bar.nix; So whereas we once had dependencies listed in three places (buildInputs, the function, and the call site), they now only need to appear in one place. * It allows overriding builtin functions. For instance, to trace all calls to ‘map’: let overrides = { map = f: xs: builtins.trace "map called!" (map f xs); # Ensure that our override gets propagated by calls to # import/scopedImport. import = fn: scopedImport overrides fn; scopedImport = attrs: fn: scopedImport (overrides // attrs) fn; # Also update ‘builtins’. builtins = builtins // overrides; }; in scopedImport overrides ./bla.nix * Similarly, it allows extending the set of builtin functions. For instance, during Nixpkgs/NixOS evaluation, the Nixpkgs library functions could be added to the default scope. There is a downside: calls to scopedImport are not memoized, unlike import. So importing a file multiple times leads to multiple parsings / evaluations. It would be possible to construct the AST only once, but that would require careful handling of variables/environments.
2014-04-04 Show position info in Boolean operationsEelco Dolstra1-1/+2
2014-04-04 Show position info in string concatenation / addition errorsEelco Dolstra1-2/+2
2014-04-04 forceString: Show position infoEelco Dolstra1-2/+2
2014-04-04 forceAttrs: Show position infoEelco Dolstra1-0/+1
2014-04-04 forceList: Show position infoEelco Dolstra1-1/+2
2014-04-04 forceInt: Show position infoEelco Dolstra1-1/+1
2014-04-04 Pass position information to primop callsEelco Dolstra1-3/+3
For example: error: `tail' called on an empty list, at /home/eelco/Dev/nixpkgs/pkgs/applications/misc/hello/ex-2/default.nix:13:7
2014-04-04 Include position info in function applicationEelco Dolstra1-1/+1
This allows error messages like: error: the anonymous function at `/etc/nixos/configuration.nix:1:1' called without required argument `foo', at `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix:77:59'
2014-03-05 Revert "Make ifs and asserts tail-recursive"Eelco Dolstra1-1/+0
This reverts commit 273322c7732093a354e86df82cf75d6604b8bce8.
2014-02-26 Warn about missing -I pathsEelco Dolstra1-1/+1
Fixes #121. Note that we don't warn about missing $NIX_PATH entries because it's intended that some may be missing (cf. the default $NIX_PATH on NixOS, which includes paths like /etc/nixos/nixpkgs for backward compatibility).
2014-01-21 Fix some clang warningsEelco Dolstra1-8/+6
2013-11-19 Add a toJSON primopEelco Dolstra1-0/+2
2013-11-18 Add a primop unsafeGetAttrPos to return the position of an attributeEelco Dolstra1-0/+1
2013-11-18 Add a symbol __curPos that expands to the current source locationEelco Dolstra1-1/+2
I.e. an attribute set { file = <string>; line = <int>; column = <int>; }.
2013-11-12 Make function calls tail-recursiveEelco Dolstra1-0/+3
2013-11-12 Make ifs and asserts tail-recursiveEelco Dolstra1-0/+1
The local Value object prevented g++ from making a tail call. Not clear why. In any case, not using a temporary makes g++ do the tail call.
2013-10-28 Slightly optimize listToAttrsEelco Dolstra1-1/+1
2013-10-24 Rename "attribute sets" to "sets"Eelco Dolstra1-2/+2
We don't have any other kind of sets so calling them attribute sets is unnecessarily verbose.
2013-10-17 Don't show <nix/derivation.nix> in stack tracesEelco Dolstra1-0/+1
Messages like while evaluating the attribute `outPath' at `/nix/store/212ngf4ph63mp6p1np2bapkfikpakfv7-nix-1.6/share/nix/corepkgs/derivation.nix:18:9': are redundant, because Nix already shows that it's evaluating a derivation: while instantiating the derivation named `firefox-24.0' at `/home/eelco/Dev/nixpkgs/pkgs/applications/networking/browsers/firefox/default.nix:131:5': while evaluating the derivation attribute `nativeBuildInputs' at `/home/eelco/Dev/nixpkgs/pkgs/stdenv/generic/default.nix:76:17':
2013-10-08 Merge VarRef into ExprVarEelco Dolstra1-1/+1
2013-09-03 nix-env: Load files in ~/.nix-defexpr on demandEelco Dolstra1-0/+6
So if you do "nix-env -qa -A nixos", then other channels won't be parsed/evaluated at all.
2013-09-03 Get rid of the parse tree cacheEelco Dolstra1-6/+6
Since we already cache files in normal form (fileEvalCache), caching parse trees is redundant. Note that getting rid of this cache doesn't actually save much memory at the moment, because parse trees are currently not freed / GC'ed.
2013-09-02 Add some support code for nix-replEelco Dolstra1-7/+8
2013-09-02 Fix whitespaceEelco Dolstra1-10/+10
2013-08-26 Simplify inherited attribute handlingShea Levy1-1/+1
This reduces the difference between inherited and non-inherited attribute handling to the choice of which env to use (in recs and lets) by setting the AttrDef::e to a new ExprVar in the parser rather than carrying a separate AttrDef::v VarRef member. As an added bonus, this allows inherited attributes that inherit from a with to delay forcing evaluation of the with's attributes. Signed-off-by: Shea Levy <shea@shealevy.com>
2013-08-19 Store Nix integers as longsEelco Dolstra1-1/+1
So on 64-bit systems, integers are now 64-bit. Fixes #158.
2013-08-14 TypoEelco Dolstra1-1/+1
2013-08-02 In the profiler output, show function names (if available)Eelco Dolstra1-1/+1
2013-07-31 Make Env smallerEelco Dolstra1-2/+2
Commit 20866a7031ca823055a221653b77986faa167329 added a ‘withAttrs’ field to Env, which is annoying because it makes every Env structure bigger and we allocate millions of them. E.g. NixOS evaluation took 18 MiB more. So this commit squeezes ‘withAttrs’ into values[0]. Probably should use a union...
2013-07-31 Avoid thunks when a fromWith var can be looked up without evaluationShea Levy1-1/+1
Signed-off-by: Shea Levy <shea@shealevy.com>
2013-07-31 Delay evaulation of `with` attrs until a variable lookup needs themShea Levy1-0/+1
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>