Ben Burdette
8b197c492e
remove comma
2022-04-09 21:54:41 -06:00
Ben Burdette
a61841ac41
don't use std::map merge
2022-04-09 07:45:23 -06:00
Ben Burdette
27d45f9eb3
minor cleanup
2022-04-08 15:46:12 -06:00
Ben Burdette
b8b8ec7101
move throw to preverve Error type; turn off debugger for tryEval
2022-04-08 12:34:27 -06:00
Ben Burdette
1a93ac8133
Merge remote-tracking branch 'upstream/master' into upstream-merge
2022-04-07 13:42:01 -06:00
Ben Burdette
50b52d5110
remove debug code
2022-04-07 12:03:18 -06:00
Ben Burdette
f41c18b221
comments
2022-03-31 09:39:18 -06:00
Ben Burdette
1096d17b65
show 'with' bindings as well as static
2022-03-31 09:37:36 -06:00
Eelco Dolstra
5cd72598fe
Add support for impure derivations
...
Impure derivations are derivations that can produce a different result
every time they're built. Example:
stdenv.mkDerivation {
name = "impure";
__impure = true; # marks this derivation as impure
outputHashAlgo = "sha256";
outputHashMode = "recursive";
buildCommand = "date > $out";
};
Some important characteristics:
* This requires the 'impure-derivations' experimental feature.
* Impure derivations are not "cached". Thus, running "nix-build" on
the example above multiple times will cause a rebuild every time.
* They are implemented similar to CA derivations, i.e. the output is
moved to a content-addressed path in the store. The difference is
that we don't register a realisation in the Nix database.
* Pure derivations are not allowed to depend on impure derivations. In
the future fixed-output derivations will be allowed to depend on
impure derivations, thus forming an "impurity barrier" in the
dependency graph.
* When sandboxing is enabled, impure derivations can access the
network in the same way as fixed-output derivations. In relaxed
sandboxing mode, they can access the local filesystem.
2022-03-31 13:43:20 +02:00
Ben Burdette
c0a567e196
remove const_cast
2022-03-29 16:44:47 -06:00
Ben Burdette
1bec3fb337
add DebugTrace for error
2022-03-25 18:15:31 -06:00
Eelco Dolstra
86b05ccd54
Only provide builtin.{getFlake,fetchClosure} is the corresponding experimental feature is enabled
...
This allows writing fallback code like
if builtins ? fetchClosure then
builtins.fetchClose { ... }
else
builtins.storePath ...
2022-03-25 14:04:18 +01:00
Eelco Dolstra
a0259a21a4
Don't hide repeated values while generating manifest.nix
...
Fixes #6243 .
2022-03-22 13:18:56 +01:00
Eelco Dolstra
732296ddc0
printValue(): <REPEAT> -> «repeated»
...
This ensures that it doesn't get parsed as a valid Nix expression.
2022-03-22 13:00:27 +01:00
John Ericson
4d6a3806d2
Decode string context straight to using StorePath
s
...
I gather decoding happens on demand, so I hope don't think this should
have any perf implications one way or the other.
2022-03-18 15:36:11 +00:00
Ben Burdette
3dfab6e534
have only one debuggerHook declaration
2022-03-14 11:58:11 -06:00
John Ericson
91adfb8894
Create some type aliases for string Contexts
2022-03-11 22:30:10 +00:00
Eelco Dolstra
aee56e0f89
Merge remote-tracking branch 'origin/eval-suggestions'
2022-03-11 12:02:26 +01:00
Eelco Dolstra
31a392dfe2
Merge pull request #5865 from pennae/memory-friendliness
...
be more memory friendly
2022-03-11 11:52:39 +01:00
pennae
c96460f352
force-inline a few much-used functions
...
these functions are called a whole lot, and they're all comparatively small.
always inlining them gives ~0.7% performance boost on eval.
before:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.935 s ± 0.052 s [User: 5.852 s, System: 0.853 s]
Range (min … max): 6.808 s … 7.026 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 329.8 ms ± 2.7 ms [User: 299.0 ms, System: 30.8 ms]
Range (min … max): 326.6 ms … 336.5 ms 20 runs
Benchmark 3: nix flakes eval --raw --impure --file expr.nix
Time (mean ± σ): 2.655 s ± 0.038 s [User: 2.364 s, System: 0.220 s]
Range (min … max): 2.574 s … 2.737 s 20 runs
after:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.912 s ± 0.036 s [User: 5.823 s, System: 0.856 s]
Range (min … max): 6.849 s … 6.980 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 325.1 ms ± 2.5 ms [User: 293.2 ms, System: 31.8 ms]
Range (min … max): 322.2 ms … 332.8 ms 20 runs
Benchmark 3: nix flakes eval --raw --impure --file expr.nix
Time (mean ± σ): 2.636 s ± 0.024 s [User: 2.352 s, System: 0.226 s]
Range (min … max): 2.574 s … 2.681 s 20 runs
2022-03-08 23:30:18 +01:00
pennae
60ed4e908a
cache singleton Envs just like Values
...
vast majority of envs is this size.
before:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.946 s ± 0.041 s [User: 5.875 s, System: 0.835 s]
Range (min … max): 6.834 s … 7.005 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 330.3 ms ± 2.5 ms [User: 299.2 ms, System: 30.9 ms]
Range (min … max): 327.5 ms … 337.7 ms 20 runs
Benchmark 3: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system'
Time (mean ± σ): 2.671 s ± 0.035 s [User: 2.370 s, System: 0.232 s]
Range (min … max): 2.597 s … 2.749 s 20 runs
after:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.935 s ± 0.052 s [User: 5.852 s, System: 0.853 s]
Range (min … max): 6.808 s … 7.026 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 329.8 ms ± 2.7 ms [User: 299.0 ms, System: 30.8 ms]
Range (min … max): 326.6 ms … 336.5 ms 20 runs
Benchmark 3: nix flakes eval --raw --impure --file expr.nix
Time (mean ± σ): 2.655 s ± 0.038 s [User: 2.364 s, System: 0.220 s]
Range (min … max): 2.574 s … 2.737 s 20 runs
2022-03-08 23:30:18 +01:00
pennae
4b2b0d3a55
remove GC_PTR_STORE_AND_DIRTY
...
turns out it's only necessary for MANUAL_VDB, which nix doesn't use. omitting
them gives a slight performance improvement on eval.
before:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.988 s ± 0.061 s [User: 5.935 s, System: 0.845 s]
Range (min … max): 6.865 s … 7.075 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 332.6 ms ± 3.9 ms [User: 299.6 ms, System: 32.9 ms]
Range (min … max): 328.1 ms … 339.1 ms 20 runs
Benchmark 3: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system'
Time (mean ± σ): 2.681 s ± 0.049 s [User: 2.382 s, System: 0.228 s]
Range (min … max): 2.607 s … 2.776 s 20 runs
after:
Benchmark 1: nix flakes search --no-eval-cache --offline ../nixpkgs hello
Time (mean ± σ): 6.946 s ± 0.041 s [User: 5.875 s, System: 0.835 s]
Range (min … max): 6.834 s … 7.005 s 20 runs
Benchmark 2: nix flakes eval -f ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix
Time (mean ± σ): 330.3 ms ± 2.5 ms [User: 299.2 ms, System: 30.9 ms]
Range (min … max): 327.5 ms … 337.7 ms 20 runs
Benchmark 3: nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system'
Time (mean ± σ): 2.671 s ± 0.035 s [User: 2.370 s, System: 0.232 s]
Range (min … max): 2.597 s … 2.749 s 20 runs
2022-03-08 23:30:18 +01:00
regnat
f6078e474d
Also display some suggestions for invalid formal arguments
...
```console
$ nix eval --expr '({ foo ? 1 }: foo) { fob = 2; }'
error: anonymous function at (string):1:2 called with unexpected argument 'fob'
at «string»:1:1:
1| ({ foo ? 1 }: foo) { fob = 2; }
| ^
Did you mean foo?
```
Not that because Nix will first check for _missing_ arguments before
checking for extra arguments, `({ foo }: foo) { fob = 1; }` will
complain about the missing `foo` argument (rather than extra `fob`) and
so won’t display a suggestion.
2022-03-08 16:40:22 +01:00
regnat
33b7514035
Try and make the darwin build happy
2022-03-08 16:07:17 +01:00
regnat
0c6e46e349
Add some suggestions to the evaluator
...
Make the evaluator show some suggestions when trying to access an
invalid field from an attrset.
```console
$ nix eval --expr '{ foo = 1; }.foa'
error: attribute 'foa' missing
at «string»:1:1:
1| { foo = 1; }.foa
| ^
Did you mean foo?
```
2022-03-08 06:21:45 +01:00
Robert Hensing
da260f579d
dupStringWithLen -> makeImmutableString
...
Refactor the `size == 0` logic into a new helper function that
replaces dupStringWithLen.
The name had to change, because unlike a `dup`-function, it does
not always allocate a new string.
2022-03-07 16:09:12 +01:00
Robert Hensing
bbf55383e7
Value::mkPath: Avoid potential crash from null string_view
2022-03-07 16:09:12 +01:00
Robert Hensing
1b978596b5
Value::mkString: Avoid crash from null string_view
2022-03-07 16:09:12 +01:00
Eelco Dolstra
e9c04c3351
Be more aggressive in hiding repeated values
...
We now memoize on Bindings / list element vectors rather than Values,
so that e.g. two Values that point to the same Bindings will be
printed only once.
2022-03-03 13:33:34 +01:00
Eelco Dolstra
ecff9d969a
printValue(): Don't show repeated values
...
Fixes #6157 .
2022-03-03 13:18:23 +01:00
Eelco Dolstra
b55d79728c
Add EvalState::coerceToStorePath() helper
...
This is useful whenever we want to evaluate something to a store path
(e.g. in get-drvs.cc).
Extracted from the lazy-trees branch (where we can require that a
store path must come from a store source tree accessor).
2022-03-02 23:58:58 +01:00
Eelco Dolstra
d974d2ad59
fetch{url,Tarball}: Remove 'narHash' attribute
...
This was introduced in #6174 . However fetch{url,Tarball} are legacy
and we shouldn't have an undocumented attribute that does the same
thing as one that already exists ('sha256').
2022-03-01 11:30:26 +01:00
Robert Hensing
ee019d0afc
Add EvalState::allowAndSetStorePathString helper
...
This switches addPath from `printStorePath` to `toRealPath`.
2022-02-28 21:37:49 +01:00
Eelco Dolstra
df552ff53e
Remove std::string alias (for real this time)
...
Also use std::string_view in a few more places.
2022-02-25 16:13:02 +01:00
Ben Burdette
3d94d3ba91
Expr refs instead of pointers
2022-02-15 15:46:45 -07:00
Ben Burdette
c9bc3735f6
quit repl from step mode
2022-02-15 09:49:25 -07:00
Ben Burdette
4cffb130e3
for primops, enter the debugger at the last DebugTrace in the stack
2022-02-11 14:14:25 -07:00
Ben Burdette
3ff5ac3586
update the eval-inline throw fns
2022-02-10 16:01:49 -07:00
Ben Burdette
bc67cb5ad1
remove fakeEnv stuff and instead use last context from the stack
2022-02-10 15:05:38 -07:00
Ben Burdette
195db83148
a few merge fixes
2022-02-04 17:35:56 -07:00
Ben Burdette
dbe3fd3735
Merge branch 'master' into debug-step
2022-02-04 15:09:40 -07:00
Eelco Dolstra
bd383d1b6f
Make most calls to determinePos() lazy
2022-02-04 00:33:21 +01:00
Eelco Dolstra
4c755c3b3f
Merge branch 'issue-3505' of https://github.com/kamadorueda/nix
2022-02-04 00:33:13 +01:00
Ben Burdette
412d58f0bb
break() primop; step and go debug commands
2022-02-03 13:15:21 -07:00
Eelco Dolstra
17e3f353df
Merge branch 'parser-improvements' of https://github.com/pennae/nix
2022-02-02 12:45:44 +01:00
pennae
d439dceb3b
optionally return string_view from coerceToString
...
we'll retain the old coerceToString interface that returns a string, but callers
that don't need the returned value to outlive the Value it came from can save
copies by using the new interface instead. for values that weren't stringy we'll
pass a new buffer argument that'll be used for storage and shouldn't be
inspected.
2022-01-27 22:15:30 +01:00
pennae
41d70a2fc8
return string_views from forceString*
...
once a string has been forced we already have dynamic storage allocated for it,
so we can easily reuse that storage instead of copying.
2022-01-27 17:15:43 +01:00
pennae
fd5aa6ee3e
allocate a GC root value for the Value cache pointer
...
keeping it as a simple data member means it won't be scanned by the GC, so
eventually the GC will collect a cache that is still referenced (resulting in
use-after-free of cache elements).
fixes #5962
2022-01-22 21:19:56 +01:00
Kevin Amado
50efc5499a
determinePos: remove from critical path
2022-01-21 16:32:43 -05:00
Kevin Amado
c3896e19d0
forceAttrs: make pos mandatory
2022-01-21 16:32:43 -05:00