@ -132,7 +132,12 @@ rec {
The exception is the ‘ options ’ attribute , which specifies
sub-options . These can be specified multiple times to allow one
module to add sub-options to an option declared somewhere else
( e . g . multiple modules define sub-options for ‘ fileSystems ’ ) . * /
( e . g . multiple modules define sub-options for ‘ fileSystems ’ ) .
' loc' is the list of attribute names where the option is located .
' opts' is a list of modules . Each module has an options attribute which
correspond to the definition of ' loc' in ' opt . file' . * /
mergeOptionDecls = loc : opts :
fold ( opt : res :
if opt . options ? default && res ? default ||
@ -143,9 +148,23 @@ rec {
then
throw " T h e o p t i o n ` ${ showOption loc } ' i n ` ${ opt . file } ' i s a l r e a d y d e c l a r e d i n ${ showFiles res . declarations } . "
else
opt . options // res //
let
/* A d d t h e m o d u l e s o f t h e c u r r e n t o p t i o n t o t h e l i s t o f m o d u l e s
already collected . The options attribute except either a list of
submodules or a submodule . For each submodule , we add the file of the
current option declaration as the file use for the submodule . If the
submodule defines any filename , then we ignore the enclosing option file . * /
options' = toList opt . options . options ;
coerceOption = file : opt :
if isFunction opt then args : { _file = file ; } // ( opt args )
else args : { _file = file ; options = opt ; } ;
submodules =
if opt . options ? options
then map ( coerceOption opt . file ) options' ++ res . options
else res . options ;
in opt . options // res //
{ declarations = [ opt . file ] ++ res . declarations ;
options = if opt . options ? options then [ ( toList opt . options . options ++ res . options ) ] else [ ] ;
options = submodules ;
}
) { inherit loc ; declarations = [ ] ; options = [ ] ; } opts ;
@ -276,12 +295,8 @@ rec {
optionSet to configOf . FIXME : remove eventually . * /
fixupOptionType = loc : opt :
let
options' = opt . options or
options = opt . options or
( throw " O p t i o n ` ${ showOption loc' } ' h a s t y p e o p t i o n S e t b u t h a s n o o p t i o n a t t r i b u t e , i n ${ showFiles opt . declarations } . " ) ;
coerce = x :
if isFunction x then x
else { config , . . . }: { options = x ; } ;
options = map coerce ( flatten options' ) ;
f = tp :
if tp . name == " o p t i o n s e t " || tp . name == " s u b m o d u l e " then
throw " T h e o p t i o n ${ showOption loc } u s e s s u b m o d u l e s w i t h o u t a w r a p p i n g t y p e , i n ${ showFiles opt . declarations } . "