-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
lib/types: make pattern of strMatching accessible #350467
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this wasn't the original intent of the functor
attribute.
We'll need to either encourage this or come up with an alternative.
@infinisil wdyt?
d2207de
to
ad7b2f3
Compare
@infinisil. I thought that it could make sense to move away from using Instead using only # Example for 'types.attrsOf'
functor = (defaultFunctor name) // {
# These could be defaults for composed types.
payload.wrapped = elemType;
type = payload: attrsOf payload.wrapped;
binOp = lhs: rhs: {
wrapped = lhs.wrapped.typeMerge rhs.wrapped.functor;
# Place for other payload merging, no need to decide between .wrapped and .payload. (see attrsWith, which uses both)
};
};
Once all types use
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After #363565, we could make functor.payload
stable (along with functor.{binOp,type}
, and kind of functor.name
), but that's a bit of a separate discussion.
While this doesn't fix a problem related to Nixpkgs (seemingly nobody has ever needed type merging for strMatching
!), this doesn't break anything and unblocks @hsjobeki with getting access to the pattern for a UI, so I think this is fine to merge :)
a25509f
to
3fe041e
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/use-cases-of-option-type-internals/57317/1 |
Makes
pattern
ofstrMatching
accessible in the option tree.Thus this allows to generate for example json-schema validation
https://json-schema.org/understanding-json-schema/reference/regular_expressions
Context: I am building a Frontend that is partially derived from those options. Exposing the pattern is very helpfull in that case.
Otherwise my users get evalModules eval stacktraces. Which is after the field was submitted / sent to the server.
If i knew the pattern upfront then i can display feedback as the user types.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.