See the added test case for the reasoning. Current order of comparison
depends on the global state and sneaks in an impurity. Introducing a
canonical order for comparisons is the only reasonable approach for
plugging this hole. The order was already unspecified and could change
for various reasons like changes to internal files/symbols used, so this
isn't exactly a breaking change.
While we have the option of choosing an arbitrary comparison order we
also choose a more efficient approach by first comparing all keys and
only then forcing any values. Notice that this is still compatible with
the non-deterministic iteration order that was used prior to this commit.
We just behave "as if" we choose the most efficient iteration order that
also happens to be strictly not less lazy.
I consider plugging this purity hole to be a requirement for adding
any sort of parallel/async eval, which would make the problem 100 times
worse by introducing true randomness to evaluation (depending on the
OS scheduling/order in which thunks finish evaluating).
Note that the choice of iteration order is consistent with snix [1],
which is good for reproducibility (modulo short circuit on non-matching keys).
[1]: a35d6558dd/snix/eval/src/value/mod.rs (L625-L628)
Nix
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 and first steps
Visit nix.dev for installation instructions and beginner tutorials.
Full reference documentation can be found in the Nix manual.
Building and developing
Follow instructions in the Nix reference manual to set up a development environment and build Nix from source.
Contributing
Check the contributing guide if you want to get involved with developing Nix.
Additional resources
Nix was created by Eelco Dolstra and developed as the subject of his PhD thesis The Purely Functional Software Deployment Model, published 2006. Today, a world-wide developer community contributes to Nix and the ecosystem that has grown around it.
- The Nix, Nixpkgs, NixOS Community on nixos.org
- Official documentation on nix.dev
- Nixpkgs is the largest, most up-to-date free software repository in the world
- NixOS is a Linux distribution that can be configured fully declaratively
- Discourse
- Matrix: #users:nixos.org for user support and #nix-dev:nixos.org for development
License
Nix is released under the LGPL v2.1.