lix/doc/manual/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
..
advanced-topics Add introductory sentence to advanced topics (#8861) 2023-08-23 15:18:25 +00:00
architecture Add description for file system objects (#8500) 2023-06-18 23:45:08 -04:00
command-ref Unify and refactor value printing 2024-03-09 03:50:06 +01:00
contributing Merge pull request #9692 from 9999years/update-clang-stdenv 2024-03-04 07:48:42 +01:00
figures
installation Merge pull request #9131 from obsidiansystems/delete-bootstrap-script 2024-03-04 04:36:52 +01:00
language Merge pull request #9032 from Ma27/structured-attrs-env-vars 2024-03-07 10:46:47 +01:00
package-management remove the Channels section 2023-07-19 09:39:04 +02:00
protocols Allow dynamic derivation deps in inputDrvs 2023-09-07 10:39:37 -04:00
release-notes Merge pull request #9393 from hercules-ci/changelog-d 2024-03-04 07:11:19 +01:00
_redirects fix location of _redirects file (#9956) 2024-02-07 11:44:06 +01:00
glossary.md disambiguate output from output path 2023-09-06 09:09:02 +02:00
introduction.md Convert short nix options to long ones 2023-05-17 08:10:30 +01:00
quick-start.md Update doc/manual/src/quick-start.md 2023-02-19 20:00:02 -05:00
SUMMARY.md.in Merge pull request #9393 from hercules-ci/changelog-d 2024-03-04 07:11:19 +01:00