aboutsummaryrefslogtreecommitdiff
path: root/src/nix/eval.cc
AgeCommit message (Collapse)Author
2023-02-20Make `--read-only` a separate mixinJohn Ericson
It is independent of SourceExprCommand, which is about parsing installables, except for the fact that parsing installables is one of the many things influenced by read-only mode.
2023-01-19Revert "Revert "Merge pull request #6204 from layus/coerce-string""Guillaume Maudoux
This reverts commit 9b33ef3879a764bed4cc2404a08344c3a697a646.
2023-01-18Revert "Merge pull request #6204 from layus/coerce-string"Robert Hensing
This reverts commit a75b7ba30f1e4f8b15e810fd18e63ee9552e0815, reversing changes made to 9af16c5f742300e831a2cc400e43df1e22f87f31.
2023-01-02Merge remote-tracking branch 'origin/master' into coerce-stringEelco Dolstra
2022-12-05Consistent capitalisationEelco Dolstra
2022-11-16Replace src/libutil/json.cc with nlohmann json generationYorick van Pelt
2022-09-07WIP: broken merge but need a git checkpointGuillaume Maudoux
2022-08-22JSON: add missing newlinesNaïm Favier
after `nix eval --json` and `nix-instantiate --eval --json`.
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-04-29Merge remote-tracking branch 'origin/master' into coerce-stringGuillaume Maudoux
2022-04-21store Symbols in a table as well, like positionspennae
this slightly increases the amount of memory used for any given symbol, but this increase is more than made up for if the symbol is referenced more than once in the EvalState that holds it. on average every symbol should be referenced at least twice (once to introduce a binding, once to use it), so we expect no increase in memory on average. symbol tables are limited to 2³² entries like position tables, and similar arguments apply to why overflow is not likely: 2³² symbols would require as many string instances (at 24 bytes each) and map entries (at 24 bytes or more each, assuming that the map holds on average at most one item per bucket as the docs say). a full symbol table would require at least 192GB of memory just for symbols, which is well out of reach. (an ofborg eval of nixpks today creates less than a million symbols!)
2022-04-21replace most Pos objects/ptrs with indexes into a position tablepennae
Pos objects are somewhat wasteful as they duplicate the origin file name and input type for each object. on files that produce more than one Pos when parsed this a sizeable waste of memory (one pointer per Pos). the same goes for ptr<Pos> on 64 bit machines: parsing enough source to require 8 bytes to locate a position would need at least 8GB of input and 64GB of expression memory. it's not likely that we'll hit that any time soon, so we can use a uint32_t index to locate positions instead.
2022-03-26nix eval: Add option `read-only`Erik Arvstedt
2022-03-18Revert extra colon at end os stringsGuillaume Maudoux
2022-03-07more fixesGuillaume Maudoux
2022-03-04Add detailed error mesage for coerceTo{String,Path}Guillaume Maudoux
2022-02-04Merge branch 'issue-3505' of https://github.com/kamadorueda/nixEelco Dolstra
2022-01-27optionally return string_view from coerceToStringpennae
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-21forceValue: make pos mandatoryKevin Amado
- Make passing the position to `forceValue` mandatory, this way we remember people that the position is important for better error messages - Add pos to all `forceValue` calls
2021-10-25toJSON: report error position for fancier outputShay Bergmann
Given flake: ```nix { description = "nix json error provenance"; inputs = {}; outputs = { self }: { jsonFunction = _: "function"; json = builtins.toJSON (_: "function"); }; } ``` - Before: ```console ❯ nix eval --json .#jsonFunction error: cannot convert a function to JSON ``` - After: ```console ❯ nix eval --json .#jsonFunction error: cannot convert a function to JSON at /nix/store/b7imf1c2j4jnkg3ys7fsfbj02s5j0i4f-source/testflake/flake.nix:4:5: 3| outputs = { self }: { 4| jsonFunction = _: "function"; | ^ 5| json = builtins.toJSON (_: "function"); ```
2021-01-27Remove mkFlag()Eelco Dolstra
2021-01-13Convert option descriptions to MarkdownEelco Dolstra
2020-12-21Add 'nix eval' manpageEelco Dolstra
2020-12-17Rename Value::normalType() -> Value::type()Silvan Mosberger
2020-12-12Use Value::normalType on all forced values instead of Value::typeSilvan Mosberger
2020-12-02nix eval: Add option to write a directoryEelco Dolstra
This is useful for generating the nix manpages, but it may have other applications (like generating configuration files without a Nix store).
2020-10-09Merge remote-tracking branch 'upstream/master' into fix-and-ci-static-buildsJohn Ericson
2020-10-06Remove static variable name clashesEelco Dolstra
This was useful for an experiment with building Nix as a single compilation unit. It's not very useful otherwise but also doesn't hurt...
2020-09-25stdout_ -> coutJohn Ericson
Better to get creative than just sprinkle arbitrary underscores.
2020-07-30Merge remote-tracking branch 'origin/master' into fix-and-ci-static-buildsMatthew Bauer
2020-06-29Rename logging->stdout to logging->stdout_Matthew Bauer
musl doesn't like this identifier
2020-06-17nix eval: Add --apply flag for post-processing the resultEelco Dolstra
2020-05-05Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-05-05nix --help: Group commandsEelco Dolstra
2020-04-16Use Logger::stdout()Eelco Dolstra
(cherry picked from commit 8f41847394524fcac40d3b5620139ca7e94a18e3)
2020-04-16Use Logger::stdout()Eelco Dolstra
2020-03-24nix edit: Support non-derivation attributesEelco Dolstra
E.g. $ nix edit .#nixosConfigurations.bla now works. (cherry picked from commit d2032edb2f86e955a8a7724a27c0c3225f386500)
2020-02-07nix edit: Support non-derivation attributesEelco Dolstra
E.g. $ nix edit .#nixosConfigurations.bla now works.
2019-12-05Make subcommand construction in MultiCommand lazyEelco Dolstra
(cherry picked from commit a0de58f471c9087d8e6cc60a6078f9940a125b15)
2019-11-27nix: Add --expr flagEelco Dolstra
This replaces the '(...)' installable syntax, which is not very discoverable. The downside is that you can't have multiple expressions or mix expressions and other installables.
2019-11-04Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2019-11-03Update nix eval --help msg to not include deprecated commandkraem
2019-06-18Make subcommand construction in MultiCommand lazyEelco Dolstra
2018-01-17nix eval: Stop progress bar before printing the resultEelco Dolstra
2018-01-17nix eval: Take only one argumentEelco Dolstra
Thus --json no longer produces a list.
2017-11-20nix eval --raw: Use coerceToString()Eelco Dolstra
Thus, $ nix eval --raw '("foo")' foo $ nix eval --raw nixpkgs.hello /nix/store/1y6ckg6khrdsvll54s5spcmf3w6ka9k4-hello-2.10 $ nix eval --raw '(/etc/resolv.conf)' /nix/store/vml92ama92i8mz013nny461mlvg8mvap-resolv.conf
2017-09-07nix eval: Add examplesEelco Dolstra
2017-05-03nix eval: Add a --raw flagEelco Dolstra
Similar to "jq -r", this prints the evaluation result (which must be a string value) unquoted.
2017-04-25Move code aroundEelco Dolstra
2017-04-25Add "nix eval" commandEelco Dolstra
This replaces "nix-instantiate --eval". The result is evaluated strictly since this seems more useful.