mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-10 09:43:30 +01:00
`assert` has the annoying property that it dumps a lot of code at the
user without the built in capability to display a nicer message. We have
worked around this using `assertMsg` which would *additionally* display
a nice message. We can do even better: By using `throw` we can make
evaluation fail before assert draws its conclusions and prevent it from
displaying the code making up the assert condition, so we get the nicer
message of `throw` and the syntactical convenience of `assert`.
Before:
nix-repl> python.override { reproducibleBuild = true; stripBytecode = false; }
trace: Deterministic builds require stripping bytecode.
error: assertion (((lib).assertMsg (reproducibleBuild -> stripBytecode)) "Deterministic builds require stripping bytecode.") failed at /home/lukas/src/nix/nixpkgs/pkgs/development/interpreters/python/cpython/2.7/default.nix:45:1
After:
nix-repl> python.override { reproducibleBuild = true; stripBytecode = false; }
error: Deterministic builds require stripping bytecode.
|
||
|---|---|---|
| .. | ||
| release-notes.xml | ||
| rl-1310.section.md | ||
| rl-1404.section.md | ||
| rl-1412.section.md | ||
| rl-1509.section.md | ||
| rl-1603.section.md | ||
| rl-1609.section.md | ||
| rl-1703.section.md | ||
| rl-1709.section.md | ||
| rl-1803.section.md | ||
| rl-1809.section.md | ||
| rl-1903.section.md | ||
| rl-1909.section.md | ||
| rl-2003.section.md | ||
| rl-2009.section.md | ||
| rl-2105.section.md | ||
| rl-2111.section.md | ||
| rl-2205.section.md | ||