aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
AgeCommit message (Collapse)Author
2022-12-02Merge pull request #7395 from obsidiansystems/evaluating-to-callingEelco Dolstra
Change "while evaluating <fun>" to "while *calling*" in trace
2022-12-02Change "while evaluating <fun>" to "while *calling*" in traceJohn Ericson
The old way was not correct. Here is an example: ``` $ nix-instantiate --eval --expr 'let x = a: throw "asdf"; in x 1' --show-trace error: asdf … while evaluating 'x' at «string»:1:9: 1| let x = a: throw "asdf"; in x 1 | ^ … from call site at «string»:1:29: 1| let x = a: throw "asdf"; in x 1 | ^ ``` and yet also: ``` $ nix-instantiate --eval --expr 'let x = a: throw "asdf"; in x' --show-trace <LAMBDA> ``` Here is the thing: in both cases we are evaluating `x`! Nix is a higher-order languages, and functions are a sort of value. When we write `x = a: ...`, `a: ...` is the expression that `x` is being defined to be, and that is already a value. Therefore, we should *never* get an trace that says "while evaluating `x`", because evaluating `a: ...` is *trival* and nothing happens during it! What is actually happening here is we are applying `x` and evaluating its *body* with arguments substituted for parameters. I think the simplest way to say is just "while *calling* `x`", and so that is what I changed it to.
2022-12-01doc: listToAttrs: add extra whitespaceAlex Ameen
2022-11-30doc: listToAttrs: fix line wrappingAlex Ameen
2022-11-30doc: listToAttrs: document repeated keysAlex Ameen
2022-11-28Merge pull request #7313 from yorickvP/nlohmann-everywhereEelco Dolstra
Replace src/libutil/json.cc with nlohmann
2022-11-25Don't use GC_STRNDUPEelco Dolstra
It calls strlen() on the input (rather than simply copying at most `size` bytes), which can fail if the input is not zero-terminated and is inefficient in any case. Fixes #7347.
2022-11-16Replace src/libutil/json.cc with nlohmann json generationYorick van Pelt
2022-11-14Merge remote-tracking branch 'nixos/master' into readFile-scan-referencesThéophane Hufschmitt
2022-11-11Restrict `readFile` context to references that appear in the stringNaïm Favier
When calling `builtins.readFile` on a store path, the references of that path are currently added to the resulting string's context. This change makes those references the *possible* context of the string, but filters them to keep only the references whose hash actually appears in the string, similarly to what is done for determining the runtime references of a path.
2022-11-10Merge pull request #7258 from ncfavier/fix-eval-error-fmtThéophane Hufschmitt
Fix printing of eval errors with two format placeholders
2022-11-04Fix printing of eval errors with two format placeholdersNaïm Favier
2022-10-25Use _typeEelco Dolstra
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2022-10-23Mark flakes with .type = "flake".Shea Levy
Fixes #7186
2022-10-12Merge pull request #7149 from amjoseph-nixpkgs/pr/intersectAttrs/valuesEelco Dolstra
parseDrvName: remove doc/impl discrepancy, add test covering the gap
2022-10-08src/libexpr/primops.cc: parseDrvName: make documentation follow implementationAdam Joseph
The documentation for `parseDrvName` does not agree with the implementation when the derivation name contains a dash which is followed by something that is neither a letter nor a digit. This commit corrects the documentation to agree with the implementation.
2022-09-26Merge pull request #7089 from NixOS/mention-accept-flake-config-in-warningEelco Dolstra
Mention `--accept-flake-config` in the related warning
2022-09-24src/libexpr/primops.cc: correct definition for intersectAttrsAdam Joseph
The current definition of `intersectAttrs` is incorrect: > Return a set consisting of the attributes in the set e2 that also exist in the > set e1. Recall that (Nix manual, section 5.1): > An attribute set is a collection of name-value-pairs (called attributes) According to the existing description of `intersectAttrs`, the following should evaluate to the empty set, since no key-value *pair* (i.e. attribute) exists in both sets: ``` builtins.intersectAttrs { x=3; } {x="foo";} ``` And yet: ``` nix-repl> builtins.intersectAttrs { x=3; } {x="foo";} { x = "foo"; } ``` Clearly the intent here was for the *names* of the resulting attribute set to be the intersection of the *names* of the two arguments, and for the values of the resulting attribute set to be the values from the second argument. This commit corrects the definition, making it match the implementation and intent.
2022-09-24Merge pull request #7010 from edolstra/ignore-shellThéophane Hufschmitt
nix develop: Ignore stdenv's $SHELL
2022-09-24Mention `--accept-flake-config` in the related warningThéophane Hufschmitt
Make sure that people who run Nix in non-interactive mode (and so don't have the possibility to interactively accept the individual flake configuration settings) are aware of this flag. Fix #7086
2022-09-16fetchurl.nix: change other use of __impureAdam Joseph
2022-09-16Update src/libexpr/fetchurl.nixAdam Joseph
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2022-09-16libexpr/fetchurl.nix: allow __impure fetchAdam Joseph
This commit adds an optional `__impure` parameter to fetchurl.nix, which allows the caller to use `libfetcher`'s fetcher in an impure derivation. This allows nixpkgs' patch-normalizing fetcher (fetchpatch) to be rewritten to use nix's internal fetchurl, thereby eliminating the awkward "you can't use fetchpatch here" banners scattered all over the place. See also: https://github.com/NixOS/nixpkgs/pull/188587
2022-09-06lockfile -> lock file for consistencyEelco Dolstra
2022-09-01Revert "Merge pull request #6621 from Kha/nested-follows"Eelco Dolstra
This reverts commit c530cda345377370c52a616d608de88b9d67cd40, reversing changes made to 4adcdff5c1d5f9f135c4ec61d690890443c19e6a.
2022-08-28Fix overlapping flake followsSebastian Ullrich
2022-08-28Fix nested flake input overridesSebastian Ullrich
2022-08-24Fix evaluation cacheEelco Dolstra
98e361ad4c1a26d4ffe4762a6f33bb9e39321a39 introduced a regression where previously stored attributes were replaced by placeholders. As a result, a command like 'nix build nixpkgs#hello' had to be executed at least twice to get caching. This code does not seem necessary for suggestions to work.
2022-08-22JSON: print paths as strings without copying them to the storeNaïm Favier
Makes `printValueAsJSON` not copy paths to the store for `nix eval --json`, `nix-instantiate --eval --json` and `nix-env --json`. Fixes https://github.com/NixOS/nix/issues/5612
2022-08-04libexpr/flake: remove `FIXME`Erik Arvstedt
Line 593 checks that all overrides (i.e. all elements of `lockFlags.inputOverrides`) are members of `overridesUsed`.
2022-08-04flakeref: fix commentErik Arvstedt
2022-08-03Fix NIX_COUNT_CALLS=1Eelco Dolstra
Also, make the JSON writer support std::string_view. Fixes #6857.
2022-07-13Simplify the check for overrides on non-existent inputsEelco Dolstra
2022-07-13Fix typo in flake.ccIkko Ashimine
non-existant -> non-existent
2022-07-12Merge pull request #6663 from Ma27/follows-invalid-inputThéophane Hufschmitt
flakes: throw an error if `follows`-declaration for an input is invalid
2022-07-12Fix debug messageEelco Dolstra
2022-07-12Move follows-check into its own functionMaximilian Bosch
2022-07-12Turn error for non-existant follows into a warningMaximilian Bosch
2022-07-12flakes: throw an error if `follows`-declaration for an input is invalidMaximilian Bosch
I recently got fairly confused why the following expression didn't have any effect { description = "Foobar"; inputs.sops-nix = { url = github:mic92/sops-nix; inputs.nixpkgs_22_05.follows = "nixpkgs"; }; } until I found out that the input was called `nixpkgs-22_05` (please note the dash vs. underscore). IMHO it's not a good idea to not throw an error in that case and probably leave end-users rather confused, so I implemented a small check for that which basically checks whether `follows`-declaration from overrides actually have corresponding inputs in the transitive flake. In fact this was done by accident already in our own test-suite where the removal of a `follows` was apparently forgotten[1]. Since the key of the `std::map` that holds the `overrides` is a vector and we have to find the last element of each vector (i.e. the override) this has to be done with a for loop in O(n) complexity with `n` being the total amount of overrides (which shouldn't be that large though). Please note that this doesn't work with nested expressions, i.e. inputs.fenix.inputs.nixpkgs.follows = "..."; which is a known problem[2]. For the expression demonstrated above, an error like this will be thrown: error: sops-nix has a `follows'-declaration for a non-existant input nixpkgs_22_05! [1] 2664a216e57169ec57d7f51be1b8383c1be83fd5 [2] https://github.com/NixOS/nix/issues/5790
2022-07-11Merge branch 'master' into ignore-tryBen Burdette
2022-07-11move ignore-try to EvalSettingsBen Burdette
2022-07-11use util.hh class instead of localBen Burdette
2022-07-11'tryEval' not 'try clause'Ben Burdette
2022-07-05builtins.traceVerbose: Post rebase fixesGytis Ivaskevicius
2022-07-05Add builtins.traceVerboseGytis Ivaskevicius
Co-Authored-By: Silvan Mosberger <contact@infinisil.com> Add builtins.traceVerbose tests
2022-06-29src/libexpr/tests/primops.cc: Quote Nix expressionsEelco Dolstra
Otherwise they don't survive reformatting, see the failure in https://github.com/NixOS/nix/pull/6721.
2022-06-26fetchGit: document `shallow` argumentGuillaume Girol
2022-06-24Merge pull request #6698 from tweag/forbid-tilde-paths-in-pure-modeThéophane Hufschmitt
Forbid the tilde expansion in pure eval mode
2022-06-23eval-cache: cast rowId to correct typeRick van Schijndel
Prevents errors when running with UBSan: /nix/store/j5vhrywqmz1ixwhsmmjjxa85fpwryzh0-gcc-11.3.0/include/c++/11.3.0/bits/stl_pair.h:353:4: runtime error: load of value 229, which is not a valid value for type 'AttrType'
2022-06-21Forbid the tilde expansion in pure eval modeThéophane Hufschmitt
Fix #6684