korora
korora copied to clipboard
Add key-dependent attrsOf type
It is sometimes useful for the type of attributes in attrsOf to depend on the current key. My internal implementation looks something like this
dependentAttrsOf =
name: mkType:
let withErrorContext = addErrorContext "in ${name} value";
in
k.typedef' name
(v:
if ! lib.isAttrs v then
typeError name v
else
withErrorContext
(mkVerify
(lib.mapAttrsToList (k: _: mkType k) v)
v));
The mkVerify is an internal function of mine which looks similar to all' in your implementation, except it shows every error instead of the first one.