about summary refs log tree commit diff
path: root/src/libexpr/eval.hh
AgeCommit message (Collapse)AuthorFilesLines
2018-06-12 Cache parse treesEelco Dolstra1-0/+8
This prevents EvalState::resetFileCache() from parsing everything all over again.
2018-05-30 Move evaluator-specific settings out of libstoreEelco Dolstra1-0/+22
2018-05-22 Make Env self-describingEelco Dolstra1-2/+2
If the Env denotes a 'with', then values[0] may be an Expr* cast to a Value*. For code that generically traverses Values/Envs, it's useful to know this.
2018-05-22 Memoise checkSourcePath()Eelco Dolstra1-0/+4
This prevents hydra-eval-jobs from statting the same files over and over again.
2018-05-02 Fix some random -Wconversion warningsEelco Dolstra1-9/+9
2018-02-17 libexpr: Optimize prim_derivationStrict by using more symbol comparisonsTuomas Tynkkynen1-1/+2
2018-02-08 Allow using RegisterPrimop to define constants.Shea Levy1-1/+1
This enables plugins to add new constants, as well as new primops.
2018-01-16 Add pure evaluation modeEelco Dolstra1-4/+4
In this mode, the following restrictions apply: * The builtins currentTime, currentSystem and storePath throw an error. * $NIX_PATH and -I are ignored. * fetchGit and fetchMercurial require a revision hash. * fetchurl and fetchTarball require a sha256 attribute. * No file system access is allowed outside of the paths returned by fetch{Git,Mercurial,url,Tarball}. Thus 'nix build -f ./foo.nix' is not allowed. Thus, the evaluation result is completely reproducible from the command line arguments. E.g. nix build --pure-eval '( let nix = fetchGit { url = https://github.com/NixOS/nixpkgs.git; rev = "9c927de4b179a6dd210dd88d34bda8af4b575680"; }; nixpkgs = fetchGit { url = https://github.com/NixOS/nixpkgs.git; ref = "release-17.09"; rev = "66b4de79e3841530e6d9c6baf98702aa1f7124e4"; }; in (import (nix + "/release.nix") { inherit nix nixpkgs; }).build.x86_64-linux )' The goal is to enable completely reproducible and traceable evaluation. For example, a NixOS configuration could be fully described by a single Git commit hash. 'nixos-rebuild' would do something like nix build --pure-eval '( (import (fetchGit { url = file:///my-nixos-config; rev = "..."; })).system ') where the Git repository /my-nixos-config would use further fetchGit calls or Git externals to fetch Nixpkgs and whatever other dependencies it has. Either way, the commit hash would uniquely identify the NixOS configuration and allow it to reproduced.
2018-01-12 import, builtins.readFile: Handle diverted storesEelco Dolstra1-0/+9
Fixes #1791
2017-10-30 Add option allowed-urisEelco Dolstra1-0/+2
This allows network access in restricted eval mode.
2017-07-26 nix-build/nix-shell: Eliminate call to nix-instantiate / nix-storeEelco Dolstra1-0/+2
Note that this removes the need for a derivation symlink, so the --drv-path and --add-drv-link flags now do nothing.
2017-07-03 Replace a few bool flags with enumsEelco Dolstra1-1/+2
Functions like copyClosure() had 3 bool arguments, which creates a severe risk of mixing up arguments. Also, implement copyClosure() using copyPaths().
2017-01-26 Add support for passing structured data to buildersEelco Dolstra1-1/+1
Previously, all derivation attributes had to be coerced into strings so that they could be passed via the environment. This is lossy (e.g. lists get flattened, necessitating configureFlags vs. configureFlagsArray, of which the latter cannot be specified as an attribute), doesn't support attribute sets at all, and has size limitations (necessitating hacks like passAsFile). This patch adds a new mode for passing attributes to builders, namely encoded as a JSON file ".attrs.json" in the current directory of the builder. This mode is activated via the special attribute __structuredAttrs = true; (The idea is that one day we can set this in stdenv.mkDerivation.) For example, stdenv.mkDerivation { __structuredAttrs = true; name = "foo"; buildInputs = [ pkgs.hello pkgs.cowsay ]; doCheck = true; hardening.format = false; } results in a ".attrs.json" file containing (sans the indentation): { "buildInputs": [], "builder": "/nix/store/ygl61ycpr2vjqrx775l1r2mw1g2rb754-bash-4.3-p48/bin/bash", "configureFlags": [ "--with-foo", "--with-bar=1 2" ], "doCheck": true, "hardening": { "format": false }, "name": "foo", "nativeBuildInputs": [ "/nix/store/10h6li26i7g6z3mdpvra09yyf10mmzdr-hello-2.10", "/nix/store/4jnvjin0r6wp6cv1hdm5jbkx3vinlcvk-cowsay-3.03" ], "propagatedBuildInputs": [], "propagatedNativeBuildInputs": [], "stdenv": "/nix/store/f3hw3p8armnzy6xhd4h8s7anfjrs15n2-stdenv", "system": "x86_64-linux" } "passAsFile" is ignored in this mode because it's not needed - large strings are included directly in the JSON representation. It is up to the builder to do something with the JSON representation. For example, in bash-based builders, lists/attrsets of string values could be mapped to bash (associative) arrays.
2016-11-26 Revert "Get rid of unicode quotes (#1140)"Eelco Dolstra1-1/+1
This reverts commit f78126bfd6b6c8477fcdbc09b2f98772dbe9a1e7. There really is no need for such a massive change...
2016-11-25 Get rid of unicode quotes (#1140)Guillaume Maudoux1-1/+1
2016-08-30 Fix GC buildEelco Dolstra1-4/+0
2016-08-29 forceBool(): Show position infoEelco Dolstra1-1/+1
2016-08-29 Add builtin function "partition"Eelco Dolstra1-1/+2
The implementation of "partition" in Nixpkgs is O(n^2) (because of the use of ++), and for some reason was causing stack overflows in multi-threaded evaluation (not sure why). This reduces "nix-env -qa --drv-path" runtime by 0.197s and memory usage by 298 MiB (in non-Boehm mode).
2016-08-23 nix build: Use Nix search pathEelco Dolstra1-2/+4
That is, unless --file is specified, the Nix search path is synthesized into an attribute set. Thus you can say $ nix build nixpkgs.hello assuming $NIX_PATH contains an entry of the form "nixpkgs=...". This is more verbose than $ nix build hello but is less ambiguous.
2016-04-14 Make the search path lazier with non-fatal errorsEelco Dolstra1-2/+8
Thus, -I / $NIX_PATH entries are now downloaded only when they are needed for evaluation. An error to download an entry is a non-fatal warning (just like non-existant paths). This does change the semantics of builtins.nixPath, which now returns the original, rather than resulting path. E.g., before we had [ { path = "/nix/store/hgm3yxf1lrrwa3z14zpqaj5p9vs0qklk-nixexprs.tar.xz"; prefix = "nixpkgs"; } ... ] but now [ { path = "https://nixos.org/channels/nixos-16.03/nixexprs.tar.xz"; prefix = "nixpkgs"; } ... ] Fixes #792.
2016-04-14 Make primop registration pluggableEelco Dolstra1-2/+2
This way we don't have to put all primops in one giant file.
2016-02-12 Merge pull request #762 from ctheune/ctheune-floatsEelco Dolstra1-0/+1
Implement floats
2016-02-04 StoreAPI -> StoreEelco Dolstra1-3/+3
Calling a class an API is a bit redundant...
2016-02-04 Eliminate the "store" global variableEelco Dolstra1-4/+6
Also, move a few free-standing functions into StoreAPI and Derivation. Also, introduce a non-nullable smart pointer, ref<T>, which is just a wrapper around std::shared_ptr ensuring that the pointer is never null. (For reference-counted values, this is better than passing a "T&", because the latter doesn't maintain the refcount. Usually, the caller will have a shared_ptr keeping the value alive, but that's not always the case, e.g., when passing a reference to a std::thread via std::bind.)
2016-01-05 Use __toString when coercing sets to strings.Shea Levy1-1/+1
For example, "${{ foo = "bar"; __toString = x: x.foo; }}" evaluates to "bar". With this, we can delay calling functions like mkDerivation, buildPythonPackage, etc. until we actually need a derivation, enabling overrides and other modifications to happen by simple attribute set update.
2016-01-05 First hit at providing support for floats in the language.Christian Theune1-0/+1
2015-10-08 forceFunction: allow functors as wellMathnerd3141-0/+2
2015-07-31 Output line number on infinite recursionIwan Aucamp1-1/+1
2015-07-23 CleanupEelco Dolstra1-13/+13
2015-07-23 Optimize empty setsEelco Dolstra1-1/+3
This reduces the number of Bindings allocations by about 10%.
2015-07-14 Move attribute set data structures into their own header file.Nicolas B. Pierron1-64/+1
This modification moves Attr and Bindings structures into their own header file which is dedicated to the attribute set representation. The goal of to isolate pieces of code which are related to the attribute set representation. Thus future modifications of the attribute set representation will only have to modify these files, and not every other file across the evaluator.
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.