about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
AgeCommit message (Collapse)AuthorFilesLines
2018-05-09 In restricted eval mode, allow access to the closure of store pathsEelco Dolstra1-1/+11
E.g. this makes nix eval --restrict-eval -I /nix/store/foo '(builtins.readFile "/nix/store/foo/symlink/bla")' (where /nix/store/foo/symlink is a symlink to another path in the closure of /nix/store/foo) succeed. This fixes a regression in Hydra compared to Nix 1.x (where there were no restrictions at all on access to the Nix store).
2018-05-02 Fix some random -Wconversion warningsEelco Dolstra1-35/+36
2018-04-03 libexpr: Make unsafeGetAttrPos not crash on noPosTuomas Tynkkynen1-1/+1
Currently e.g. `builtins.unsafeGetAttrPos "abort" builtins` will eventually segfault because pos->file is an unset Symbol. Found by afl-fuzz.
2018-03-14 concatLists: Don't pass NULL pointers to memcpy.Shea Levy1-1/+2
This is UB, even if the size is 0. See #1976. Fixes #1976.
2018-02-28 Actually fix nixDataDir in non-canonical pathShea Levy1-1/+1
2018-02-22 Merge branch 'data-dir-non-canon' of https://github.com/shlevy/nixEelco Dolstra1-1/+1
2018-02-22 Fix restricted mode when installing in non-canonical data dirShea Levy1-1/+1
2018-02-17 libexpr: Optimize prim_derivationStrict by using more symbol comparisonsTuomas Tynkkynen1-0/+4
2018-02-17 libexpr: Rely on Boehm returning zeroed memory in EvalState::allocEnv()Tuomas Tynkkynen1-4/+3
Boehm guarantees that memory returned by GC_malloc() is zeroed, so take advantage of that.
2018-02-13 Merge branch 'register-constant' of https://github.com/shlevy/nixEelco Dolstra1-1/+7
2018-02-11 Nix stats: flatten statisticsFrederik Rietdijk1-3/+6
Flattens the list of statistics as suggested in https://github.com/NixOS/ofborg/issues/67. This makes it easier to work with.
2018-02-08 Allow using RegisterPrimop to define constants.Shea Levy1-1/+7
This enables plugins to add new constants, as well as new primops.
2018-02-07 Merge pull request #1816 from shlevy/add-pathEelco Dolstra1-1/+1
Add path primop.
2018-02-06 Add path primop.Shea Levy1-1/+1
builtins.path allows specifying the name of a path (which makes paths with store-illegal names now addable), allows adding paths with flat instead of recursive hashes, allows specifying a filter (so is a generalization of filterSource), and allows specifying an expected hash (enabling safe path adding in pure mode).
2018-02-06 checkURI(): Check file URIs against allowedPathsEelco Dolstra1-0/+12
This makes e.g. 'fetchGit ./.' work (assuming that ./. is an allowed path).
2018-01-19 Don't use [[noreturn]]Eelco Dolstra1-6/+3
2018-01-16 Add pure evaluation modeEelco Dolstra1-26/+39
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/+10
Fixes #1791
2017-10-30 Add option allowed-urisEelco Dolstra1-0/+20
This allows network access in restricted eval mode.
2017-10-29 nix repl :t: Indicate strings that have a contextEelco Dolstra1-1/+1
2017-07-30 Replace Unicode quotes in user-facing strings by ASCIIJörg Thalheim1-17/+17
Relevant RFC: NixOS/rfcs#4 $ ag -l | xargs sed -i -e "/\"/s/’/'/g;/\"/s/‘/'/g"
2017-07-03 Replace a few bool flags with enumsEelco Dolstra1-0/+1
Functions like copyClosure() had 3 bool arguments, which creates a severe risk of mixing up arguments. Also, implement copyClosure() using copyPaths().
2017-05-16 Improve progress indicatorEelco Dolstra1-1/+1
2017-04-14 Shut up some warningsEelco Dolstra1-1/+1
2017-02-22 Explicitly model all settings and fail on unrecognized onesDan Peebles1-1/+1
Previously, the Settings class allowed other code to query for string properties, which led to a proliferation of code all over the place making up new options without any sort of central registry of valid options. This commit pulls all those options back into the central Settings class and removes the public get() methods, to discourage future abuses like that. Furthermore, because we know the full set of options ahead of time, we now fail loudly if someone enters an unrecognized option, thus preventing subtle typos. With some template fun, we could probably also dump the full set of options (with documentation, defaults, etc.) to the command line, but I'm not doing that yet here.
2017-01-26 Add support for passing structured data to buildersEelco Dolstra1-0/+2
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.
2017-01-26 Bindings: Add a method for iterating in lexicographically sorted orderEelco Dolstra1-7/+3
2016-11-26 Revert "Get rid of unicode quotes (#1140)"Eelco Dolstra1-17/+17
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-17/+17
2016-08-29 forceBool(): Show position infoEelco Dolstra1-2/+2
2016-08-29 Add builtin function "partition"Eelco Dolstra1-0/+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-29 callFunction: Copy functors to the heapShea Levy1-4/+11
Normally it's impossible to take a reference to the function passed to callFunction, so some callers (e.g. ExprApp::eval) allocate that value on the stack. For functors, a reference to the functor itself may be kept, so we need to have it on the heap. Fixes #1045
2016-08-23 nix build: Use Nix search pathEelco Dolstra1-3/+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-06-01 Make the store directory a member variable of StoreEelco Dolstra1-2/+2
2016-04-25 Improved logging abstractionEelco Dolstra1-1/+1
This also gets rid of --log-type, since the nested log type isn't useful in a multi-threaded situation, and nobody cares about the "pretty" log type.
2016-04-14 Make $NIX_PATH parsing more robustEelco Dolstra1-5/+32
2016-04-14 Make the search path lazier with non-fatal errorsEelco Dolstra1-3/+7
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-02-12 Merge pull request #762 from ctheune/ctheune-floatsEelco Dolstra1-2/+55
Implement floats
2016-02-04 StoreAPI -> StoreEelco Dolstra1-1/+1
Calling a class an API is a bit redundant...
2016-02-04 Eliminate the "store" global variableEelco Dolstra1-1/+2
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/+9
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 Fix up float parsing.Christian Theune1-0/+1
2016-01-05 First hit at providing support for floats in the language.Christian Theune1-2/+54
2015-11-25 autoCallFunction: Auto-call functorsShea Levy1-0/+11
2015-10-29 int2String() -> std::to_string()Eelco Dolstra1-1/+1
2015-10-08 isFunctor: SimplifyEelco Dolstra1-0/+6
2015-10-08 forceFunction: allow functors as wellMathnerd3141-1/+1
2015-07-31 Fix stack consumptionEelco Dolstra1-5/+0
2015-07-31 Output line number on infinite recursionIwan Aucamp1-8/+8
2015-07-23 CleanupEelco Dolstra1-5/+0