Sergei Zimmerman 2d9bb33ba2 libexpr: Make attribute set comparison use deterministic lexicographic order of attributes
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)
2026-02-26 15:53:47 +03:00
2026-02-25 01:41:11 -05:00
2026-02-25 17:29:56 -05:00
2024-02-01 01:01:39 +01:00
2025-11-04 22:55:18 +03:00
2026-01-25 22:08:40 +03:00
2025-12-10 17:35:28 +01:00
2025-01-24 17:04:02 +01:00
2024-10-14 11:21:24 -04:00
2025-06-11 22:08:03 +00:00
2026-01-04 21:45:34 -05:00
2022-01-24 13:28:21 +01:00

Nix

Open Collective supporters CI

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.

License

Nix is released under the LGPL v2.1.

Description
Nix, the purely functional package manager
Readme Cite this repository 163 MiB
Languages
C++ 78.1%
Shell 9.7%
Nix 7.5%
Meson 1.8%
C 1.3%
Other 1.6%