about summary refs log tree commit diff
path: root/src/libexpr/eval.hh
AgeCommit message (Collapse)AuthorFilesLines
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>
2012-11-28 nix-env -q --out-path: Support multiple outputsEelco Dolstra1-1/+1
We now print all output paths of a package, e.g. openssl-1.0.0i bin=/nix/store/gq2mvh0wb9l90djvsagln3aqywqmr6vl-openssl-1.0.0i-bin;man=/nix/store/7zwf5r5hsdarl3n86dasvb4chm2xzw9n-openssl-1.0.0i-man;/nix/store/cj7xvk7fjp9q887359j75pw3pzjfmqf1-openssl-1.0.0i or (in XML mode) <item attrPath="openssl" name="openssl-1.0.0i" system="x86_64-linux"> <output name="bin" path="/nix/store/gq2mvh0wb9l90djvsagln3aqywqmr6vl-openssl-1.0.0i-bin" /> <output name="man" path="/nix/store/7zwf5r5hsdarl3n86dasvb4chm2xzw9n-openssl-1.0.0i-man" /> <output name="out" path="/nix/store/cj7xvk7fjp9q887359j75pw3pzjfmqf1-openssl-1.0.0i" /> </item>
2012-11-27 Optionally ignore null-valued derivation attributesEelco Dolstra1-1/+1
This allows adding attributes like attr = if stdenv.system == "bla" then something else null; without changing the resulting derivation on non-<bla> platforms. We once considered adding a special "ignore" value for this purpose, but using null seems more elegant.
2012-11-26 nix-instantiate: Fix read-only evaluationEelco Dolstra1-1/+1
2012-10-03 Add a ‘--repair’ flag to nix-instantiateEelco Dolstra1-0/+4
This allows repairing corrupted derivations and other source files.
2012-08-13 Add a primop ‘concatLists’Eelco Dolstra1-0/+2
This can serve as a generic efficient list builder. For instance, the function ‘catAttrs’ in Nixpkgs can be rewritten from attr: l: fold (s: l: if hasAttr attr s then [(getAttr attr s)] ++ l else l) [] l to attr: l: builtins.concatLists (map (s: if hasAttr attr s then [(getAttr attr s)] else []) l) Statistics before: time elapsed: 1.08683 size of a value: 24 environments allocated: 1384376 (35809568 bytes) list elements: 6946783 (55574264 bytes) list concatenations: 37434 values allocated: 1760440 (42250560 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18273 number of thunks: 1297673 number of thunks avoided: 1380759 number of attr lookups: 430802 number of primop calls: 628912 number of function calls: 1333544 Statistics after (including new catAttrs): time elapsed: 0.959854 size of a value: 24 environments allocated: 1010198 (26829296 bytes) list elements: 1984878 (15879024 bytes) list concatenations: 30488 values allocated: 1589760 (38154240 bytes) attribute sets allocated: 392040 right-biased unions: 186334 values copied in right-biased unions: 591137 symbols in symbol table: 18274 number of thunks: 1040925 number of thunks avoided: 1038428 number of attr lookups: 438419 number of primop calls: 474844 number of function calls: 959366