lix/src
eldritch horrors 512c1f05c3 Unify and refactor value printing
Previously, there were two mostly-identical value printers -- one in
`libexpr/eval.cc` (which didn't force values) and one in
`libcmd/repl.cc` (which did force values and also printed ANSI color
codes).

This PR unifies both of these printers into `print.cc` and provides a
`PrintOptions` struct for controlling the output, which allows for
toggling whether values are forced, whether repeated values are tracked,
and whether ANSI color codes are displayed.

Additionally, `PrintOptions` allows tuning the maximum number of
attributes, list items, and bytes in a string that will be displayed;
this makes it ideal for contexts where printing too much output (e.g.
all of Nixpkgs) is distracting. (As requested by @roberth in
https://github.com/NixOS/nix/pull/9554#issuecomment-1845095735)

Please read the tests for example output.

Future work:
- It would be nice to provide this function as a builtin, perhaps
  `builtins.toStringDebug` -- a printing function that never fails would
  be useful when debugging Nix code.
- It would be nice to support customizing `PrintOptions` members on the
  command line, e.g. `--option to-string-max-attrs 1000`.

(cherry picked from commit 0fa08b451682fb3311fe58112ff05c4fe5bee3a4, )

===

Restore ambiguous value printer for `nix-instantiate`

The Nix team has requested that this output format remain unchanged.
I've added a warning to the man page explaining that `nix-instantiate
--eval` output will not parse correctly in many situations.

(cherry picked from commit df84dd4d8dd3fd6381ac2ca3064432ab31a16b79)

Change-Id: I7cca6b4b53cd0642f2d49af657d5676a8554c9f8
2024-03-09 03:50:06 +01:00
..
build-remote Merge pull request #9838 from obsidiansystems/systemTypes-set 2024-03-04 08:39:24 +01:00
libcmd Unify and refactor value printing 2024-03-09 03:50:06 +01:00
libexpr Unify and refactor value printing 2024-03-09 03:50:06 +01:00
libfetchers Merge pull request #9324 from 9999years/fix-8854-take-2 2024-03-07 14:50:43 +01:00
libmain Merge pull request #9465 from obsidiansystems/build-dir 2024-03-04 07:11:25 +01:00
libstore Merge pull request #9560 from obsidiansystems/serve-proto-unkeyed-valid-path-info-serializer 2024-03-07 12:37:33 +01:00
libutil Unify and refactor value printing 2024-03-09 03:50:06 +01:00
nix Merge changes I03bbff94,I778edad1,Iaa80073b,Ib1d58fe4 into main 2024-03-07 18:48:17 -07:00
nix-build Merge pull request #9582 from pennae/misc-opts 2024-03-04 07:32:31 +01:00
nix-channel Merge pull request #10054 from syvb/channel-unpack-count 2024-03-04 09:25:17 +01:00
nix-collect-garbage Clean up a few things related to profiles (#8526) 2023-06-19 04:04:59 +00:00
nix-copy-closure Merge pull request #9277 from keszybz/file-permissions 2024-03-04 05:26:17 +01:00
nix-env Unify and refactor value printing 2024-03-09 03:50:06 +01:00
nix-instantiate Unify and refactor value printing 2024-03-09 03:50:06 +01:00
nix-store Merge pull request #9560 from obsidiansystems/serve-proto-unkeyed-valid-path-info-serializer 2024-03-07 12:37:33 +01:00
resolve-system-dependencies Remove FormatOrString and remaining uses of format() 2023-03-02 15:57:54 +01:00
toml11 Replace cpptoml with toml11 2021-12-17 22:03:33 +01:00