Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: NixOS-style assertions support #77

Open
shanesveller opened this issue Nov 25, 2022 · 3 comments
Open

Feature request: NixOS-style assertions support #77

shanesveller opened this issue Nov 25, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@shanesveller
Copy link

shanesveller commented Nov 25, 2022

I'd like to offer consumers of my flake modules feedback if they set options to semantically incorrect values, or use mutually-exclusive options simultaneously.

If some guidance is available I'd be happy to try to implement this myself.

@shanesveller
Copy link
Author

If the contract were exactly the same as NixOS's version ({ assertion = someBool, message = someStr }), realized at evaluation time, that would satisfy my goals well.

@roberth
Copy link
Member

roberth commented Nov 25, 2022

Unlike NixOS, the attributes of a flake are often accessed individually, which means that laziness plays a more important role; somewhat comparable to Nixpkgs. Assertions require more to be evaluated, including things that may not have been evaluated otherwise.
For this reason, and potentially to avoid infinite recursions caused by the extra strictness, this feature should be a bit different from the NixOS assertions. Probably they should come with a flake attribute path that tells flake-parts when to evaluate the assertions.

@shanesveller
Copy link
Author

Some of my loose reading of nixpkgs' lib.types implies that I could put some ad-hoc logic in as custom check on the types I declare for my options, if it doesn't require any adjacent information to determine the validity, but I don't know how maintainable or effective that would be. The source has a big cautionary warning above it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants