about summary refs log tree commit diff
path: root/lib/asserts.nix
AgeCommit message (Collapse)AuthorFilesLines
2024-03-07doc: lib.asserts migrate to doc-comments (#292310)Johannes Kirschbauer1-44/+106
2023-11-09lib: add asserts.assertEachOneOfProfpatsch1-0/+29
Along the lines of `assertOneOf`, but expects a list of values to be compared. This gives a good error message and is useful for lists of values, like `supportedGhcVersions` in the arguments of `haskell-language-server`.
2022-12-08doc: auto-generate asserts and attrset library docsRyan Mulligan1-4/+15
If all the docs are auto-generated, it should be easier to convert them to Commonmark. Co-Authored-By: Valentin Gagarin <valentin.gagarin@tweag.io> Co-Authored-By: Silvan Mosberger <contact@infinisil.com>
2022-01-19lib/asserts: use throw to display message for assertMsgsternenseemann1-12/+10
`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.
2018-09-06lib: move assertMsg and assertOneOf to their own library fileProfpatsch1-0/+44
Since the `assertOneOf` uses `lib.generators`, they are not really trivial anymore and should go into their own library file.