3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/lib
sternenseemann 48965506a1 lib/asserts: use throw to display message for assertMsg
`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.
2022-01-19 00:50:06 +01:00
..
systems lib.systems.supported: remove aarch64-darwin from Tier 3 list 2021-12-16 17:51:21 +01:00
tests lib: fix flake check 2021-12-13 12:03:40 +01:00
asserts.nix lib/asserts: use throw to display message for assertMsg 2022-01-19 00:50:06 +01:00
attrsets.nix Merge pull request #152392 from polykernel/attrset-optimizations-patch-1 2022-01-11 16:01:52 +00:00
cli.nix
customisation.nix lib: make extendDerivation lighter on eval 2021-10-15 16:39:10 +02:00
debug.nix
default.nix lib.checkListOfEnum: init 2022-01-09 19:21:08 -03:00
deprecated.nix
fetchers.nix
filesystem.nix
fixed-points.nix lib.compose{Many,}Extensions: Make compatible with nix flake check 2021-08-26 09:12:17 -04:00
flake.nix
generators.nix Merge pull request #131205 from Ma27/showdefs-overflow 2021-09-29 11:03:31 +02:00
kernel.nix
licenses.nix licenses: add CAPEC 2021-10-15 23:10:34 +02:00
lists.nix lib/lists: mutuallyExclusive function optimization 2021-11-01 16:29:01 -04:00
meta.nix lib/meta: add getLicenseFromSpdxId function 2021-12-02 18:33:48 +08:00
minver.nix
modules.nix lib/modules: extract multiply-used value in byName 2021-12-28 16:53:50 +01:00
options.nix nixos/documentation: split options doc build 2022-01-02 19:46:13 +01:00
sources.nix lib.cleanSource: ignore sockets 2021-09-17 10:03:00 +00:00
strings-with-deps.nix
strings.nix lib: fix escapeXML example in documentation 2021-11-02 22:43:25 +01:00
trivial.nix lib.checkListOfEnum: init 2022-01-09 19:21:08 -03:00
types.nix lib.evalModules: Add extendModules and type to result 2021-11-01 09:34:07 +01:00
versions.nix
zip-int-bits.nix