A modern, delicious implementation of the Nix package manager, focused on correctness, usability, and growth — and committed to doing right by its community
Find a file
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
.github Put functional tests in tests/functional 2023-12-01 12:06:43 -05:00
config Run autoupdate 2021-06-01 11:42:38 +02:00
contrib function-trace: always show the trace 2019-09-18 23:23:21 +02:00
doc Unify and refactor value printing 2024-03-09 03:50:06 +01:00
m4 Merge pull request #6258 from obsidiansystems/gcc-bug-ergonomics 2024-03-04 05:24:33 +01:00
maintainers Merge pull request #9393 from hercules-ci/changelog-d 2024-03-04 07:11:19 +01:00
misc Merge pull request #9573 from hercules-ci/rl-next-md-frontmatter 2024-03-04 07:12:09 +01:00
mk Merge pull request #5145 from fedepell/local_doc_build_5140 2024-03-05 23:01:05 +01:00
perl Merge pull request #9152 from obsidiansystems/split-out-perl-nix 2024-03-04 04:37:44 +01:00
scripts Merge pull request #10001 from abathur/fix_macos_daemon_perms 2024-03-04 09:25:17 +01:00
src Unify and refactor value printing 2024-03-09 03:50:06 +01:00
tests Unify and refactor value printing 2024-03-09 03:50:06 +01:00
unit-test-data/libstore Merge pull request #9560 from obsidiansystems/serve-proto-unkeyed-valid-path-info-serializer 2024-03-07 12:37:33 +01:00
.dir-locals.el .dir-locals.el: Set c-block-comment-prefix 2020-07-10 11:21:06 +02:00
.editorconfig Add .editorconfig 2017-06-05 22:57:28 +01:00
.gitignore Merge pull request #10085 from ShamrockLee/ignore-obsolete-testdir 2024-03-05 23:36:31 -07:00
.version Update version to 2.90.0 2024-03-07 19:57:39 -07:00
boehmgc-coroutine-sp-fallback.diff Merge pull request #8887 from obsidiansystems/bsd-cross-ci 2024-03-04 04:36:04 +01:00
boehmgc-traceable_allocator-public.diff Merge pull request #9430 from hercules-ci/remove-vlas 2024-03-04 07:11:25 +01:00
configure.ac Merge pull request #9844 from NixOS/pkg-config-gmock 2024-03-04 08:47:39 +01:00
CONTRIBUTING.md Put functional tests in tests/functional 2023-12-01 12:06:43 -05:00
COPYING * Change this to LGPL to keep the government happy. 2006-04-25 16:41:06 +00:00
default.nix add flake-compat to flake.nix and use sha256 in default.nix 2023-03-06 21:11:24 +01:00
docker.nix fix "add an option to include flake-registry..." 2023-05-16 14:35:31 +02:00
flake.lock flake.nix: upgrade to nixos-23.11 2024-03-08 23:59:01 +00:00
flake.nix flake.nix: upgrade to nixos-23.11 2024-03-08 23:59:01 +00:00
local.mk Merge pull request #9106 from Ericson2314/positive-source-filtering 2024-03-04 04:36:42 +01:00
Makefile Merge pull request #10074 from lf-/jade/ban-implicit-fallthrough 2024-03-07 00:11:12 -07:00
Makefile.config.in Merge pull request #9106 from Ericson2314/positive-source-filtering 2024-03-04 04:36:42 +01:00
precompiled-headers.h Config: Use nlohmann/json 2020-08-20 11:02:16 +02:00
README.md Improve hacking.md 2023-02-13 12:00:00 +04:00
shell.nix Remove url literals 2022-01-24 13:28:21 +01:00

Nix

Open Collective supporters Test

Nix is a powerful package manager for Linux and other Unix systems that makes package management reliable and reproducible. Please refer to the Nix manual for more details.

Installation

On Linux and macOS the easiest way to install Nix is to run the following shell command (as a user other than root):

$ curl -L https://nixos.org/nix/install | sh

Information on additional installation methods is available on the Nix download page.

Building And Developing

See our Hacking guide in our manual for instruction on how to to set up a development environment and build Nix from source.

Additional Resources

License

Nix is released under the LGPL v2.1.