aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.cc
AgeCommit message (Collapse)Author
2020-03-17Require shallow clones to be requested explicitlyEelco Dolstra
If you do a fetchTree on a Git repository, whether the result contains a revCount attribute should not depend on whether that repository happens to be a shallow clone or not. That would complicate caching a lot and would be semantically messy. So applying fetchTree/fetchGit to a shallow repository is now an error unless you pass the attribute 'shallow = true'. If 'shallow = true', we don't return revCount, even if the repository is not actually shallow. Note that Nix itself is not doing shallow clones at the moment. But it could do so as an optimisation if the user specifies 'shallow = true'. Issue #2988.
2020-01-21Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-01-13Tweak error messageEelco Dolstra
2020-01-11libexpr: show expression in assertion errorsDaiderd Jordan
Includes the expression of the condition in the assertion message if the assertion failed, making assertions much easier to debug. eg. error: assertion (withPython -> (python2Packages != null)) failed at pkgs/tools/security/nmap/default.nix:11:1
2020-01-06Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-01-05Hide FunctionCallTrace constructor/destructorEelco Dolstra
This prevents them from being inlined. On gcc 9, this reduces the stack size needed for nix-instantiate '<nixpkgs>' -A texlive.combined.scheme-full --dry-run from 12.9 MiB to 4.8 MiB.
2019-12-11Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-12-10Make the Store API more type-safeEelco Dolstra
Most functions now take a StorePath argument rather than a Path (which is just an alias for std::string). The StorePath constructor ensures that the path is syntactically correct (i.e. it looks like <store-dir>/<base32-hash>-<name>). Similarly, functions like buildPaths() now take a StorePathWithOutputs, rather than abusing Path by adding a '!<outputs>' suffix. Note that the StorePath type is implemented in Rust. This involves some hackery to allow Rust values to be used directly in C++, via a helper type whose destructor calls the Rust type's drop() function. The main issue is the dynamic nature of C++ move semantics: after we have moved a Rust value, we should not call the drop function on the original value. So when we move a value, we set the original value to bitwise zero, and the destructor only calls drop() if the value is not bitwise zero. This should be sufficient for most types. Also lots of minor cleanups to the C++ API to make it more modern (e.g. using std::optional and std::string_view in some places).
2019-12-10EvalState::callFunction(): Make FunctionCallTrace use less stack spaceEelco Dolstra
The FunctionCallTrace object consumes a few hundred bytes of stack space, even when tracing is disabled. This was causing stack overflows: $ nix-instantiate '<nixpkgs> -A texlive.combined.scheme-full --dry-run error: stack overflow (possible infinite recursion) This is with the default stack size of 8 MiB. Putting the object on the heap reduces stack usage to < 5 MiB.
2019-12-05Move #includeEelco Dolstra
(cherry picked from commit 8beedd44861d1fe7208609ee8d231ca1c02dedf6)
2019-12-04Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-11-28Remove builtins.valueSizeEelco Dolstra
Fixes #3246.
2019-11-25Ensure enough space in attrset bindings when using both __overrides and ↵Puck Meerburg
dynamic attributes
2019-11-22Turn NIX_PATH into a config settingEelco Dolstra
This allows it to be set in nix.conf.
2019-11-22Provide a default value for NIX_PATHEelco Dolstra
2019-11-22getEnv(): Return std::optionalEelco Dolstra
This allows distinguishing between an empty value and no value.
2019-11-20Move #includeEelco Dolstra
2019-11-11Merge pull request #3219 from Ericson2314/semicolonsEelco Dolstra
Fix extra semicolons warnings
2019-11-10Remove unneeded semicolonsJohn Ericson
2019-11-04Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-10-27Merge branch 'tojson-tostring-fix' of https://github.com/mayflower/nixEelco Dolstra
2019-10-27builtins.toJSON: fix __toString usageRobin Gloster
2019-10-10Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-10-09OCD performance fix: {find,count}+insert => insertEelco Dolstra
2019-09-09Require flake.nix to be an attrset (not a non-trivial thunk)Eelco Dolstra
2019-09-09Don't allow arbitrary computations in flake attributesEelco Dolstra
E.g. you can write 'edition = 201909' but not 'edition = 201909 + 0'. Fixes #3075.
2019-08-30Extract flake dependencies from the 'outputs' argumentsEelco Dolstra
That is, instead of inputs = [ "nixpkgs" ]; outputs = inputs: ... inputs.nixpkgs ...; you can write outputs = { nixpkgs }: ... inputs.nixpkgs ...;
2019-08-29Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-08-14Track function start and ends for flame graphsGraham Christensen
With this patch, and this file I called `log.py`: #!/usr/bin/env nix-shell #!nix-shell -i python3 -p python3 --pure import sys from pprint import pprint stack = [] timestack = [] for line in open(sys.argv[1]): components = line.strip().split(" ", 2) if components[0] != "function-trace": continue direction = components[1] components = components[2].rsplit(" ", 2) loc = components[0] _at = components[1] time = int(components[2]) if direction == "entered": stack.append(loc) timestack.append(time) elif direction == "exited": dur = time - timestack.pop() vst = ";".join(stack) print(f"{vst} {dur}") stack.pop() and: nix-instantiate --trace-function-calls -vvvv ../nixpkgs/pkgs/top-level/release.nix -A unstable > log.matthewbauer 2>&1 ./log.py ./log.matthewbauer > log.matthewbauer.folded flamegraph.pl --title matthewbauer-post-pr log.matthewbauer.folded > log.matthewbauer.folded.svg I can make flame graphs like: http://gsc.io/log.matthewbauer.folded.svg --- Includes test cases around function call failures and tryEval. Uses RAII so the finish is always called at the end of the function.
2019-06-05Move flake-related stuff to src/libexpr/flakeEelco Dolstra
2019-05-22Fetch the flake registry from the NixOS/flake-registry repoEelco Dolstra
2019-05-08Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-05-07Make the URL/path of the global flake registry configurableEelco Dolstra
2019-04-11Add environment variable NIX_SHOW_SYMBOLS for dumping the symbol tableEelco Dolstra
2019-03-26Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-03-21eval: improve type description for primops and applied primopsLinus Heckemann
This can make type errors a little easier to understand.
2019-02-12Improve flake referencesEelco Dolstra
2019-02-11Initial flake supportEelco Dolstra
2019-02-11Make constant primops lazyEelco Dolstra
2018-12-31EvalState::resetFileCache: clear parse cache as well as eval cacheWill Dietz
Fixes #2546. (at least the basic reproduction I've been testing)
2018-09-05Convert NIX_COUNT_CALLS to JSON tooEelco Dolstra
2018-09-05Log stats to stderrEelco Dolstra
We shouldn't pollute stdout.
2018-09-02remove the old text format outputMichael Bishop
2018-09-01add JSON to NIX_SHOW_STATSMichael Bishop
2018-09-01improve the stats when profilingMichael Bishop
2018-08-03Merge pull request #2326 from aszlig/fix-symlink-leakEelco Dolstra
Fix symlink leak in restricted eval mode
2018-08-03Fix symlink leak in restricted eval modeaszlig
In EvalState::checkSourcePath, the path is checked against the list of allowed paths first and later it's checked again *after* resolving symlinks. The resolving of the symlinks is done via canonPath, which also strips out "../" and "./". However after the canonicalisation the error message pointing out that the path is not allowed prints the symlink target in the error message. Even if we'd suppress the message, symlink targets could still be leaked if the symlink target doesn't exist (in this case the error is thrown in canonPath). So instead, we now do canonPath() without symlink resolving first before even checking against the list of allowed paths and then later do the symlink resolving and checking the allowed paths again. The first call to canonPath() should get rid of all the "../" and "./", so in theory the only way to leak a symlink if the attacker is able to put a symlink in one of the paths allowed by restricted evaluation mode. For the latter I don't think this is part of the threat model, because if the attacker can write to that path, the attack vector is even larger. Signed-off-by: aszlig <aszlig@nix.build>
2018-07-31Merge branch 'prim_mapAttr-fix' of https://github.com/volth/nixEelco Dolstra
2018-07-11Remove unused function printStats2()Eelco Dolstra
Closes #2282.
2018-07-06prim_mapAttrs: `f' must be evaluated lazily to avoid infinite recursionvolth