@ -250,14 +250,14 @@ rec {
# Add in the default value for this option, if any.
defs' = ( optional ( opt ? default )
{ file = head opt . declarations ; value = mkOptionDefault opt . default ; } ) ++ defs ;
# Handle properties, check types, and merge everything together
inherit ( mergeDefinitions loc opt . type defs' ) defsFinal mergedValue ;
inherit ( mergeDefinitions loc opt . type defs' ) isDefined defsFinal mergedValue ;
files = map ( def : def . file ) defsFinal ;
merged =
if defsFinal == [ ] then
throw " T h e o p t i o n ` ${ showOption loc } ' i s u s e d b u t n o t d e f i n e d . "
else
mergedValue ;
if isDefined then mergedValue
else throw " T h e o p t i o n ` ${ showOption loc } ' i s u s e d b u t n o t d e f i n e d . " ;
# Finally, apply the ‘apply’ function to the merged
# value. This allows options to yield a value computed
# from the definitions.
@ -265,8 +265,7 @@ rec {
in opt //
{ value = addErrorContext " w h i l e e v a l u a t i n g t h e o p t i o n ` ${ showOption loc } ' : " value ;
definitions = map ( def : def . value ) defsFinal ;
isDefined = defsFinal != [ ] ;
inherit files ;
inherit isDefined files ;
} ;
# Merge definitions of a value of a given type
@ -295,6 +294,11 @@ rec {
if type . check def . value then res
else throw " T h e o p t i o n v a l u e ` ${ showOption loc } ' i n ` ${ def . file } ' i s n o t a ${ type . name } . " )
( type . merge loc defsFinal ) defsFinal ;
isDefined = defsFinal != [ ] ;
optionalValue =
if isDefined then { value = mergedValue ; }
else { } ;
} ;
/* G i v e n a c o n f i g s e t , e x p a n d m k M e r g e p r o p e r t i e s , a n d p u s h d o w n t h e