Merge pull request #66407 from Infinisil/fix-option-rename

lib/modules: Use options `apply` function even if no values are defined
This commit is contained in:
Silvan Mosberger 2019-08-27 22:06:23 +02:00 committed by GitHub
commit 91f6a681e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -323,16 +323,14 @@ rec {
else
mergeDefinitions loc opt.type defs';
# Check whether the option is defined, and apply the apply
# function to the merged value. This allows options to yield a
# value computed from the definitions.
value =
if !res.isDefined then
throw "The option `${showOption loc}' is used but not defined."
else if opt ? apply then
opt.apply res.mergedValue
else
res.mergedValue;
# The value with a check that it is defined
valueDefined = if res.isDefined then res.mergedValue else
throw "The option `${showOption loc}' is used but not defined.";
# Apply the 'apply' function to the merged value. This allows options to
# yield a value computed from the definitions
value = if opt ? apply then opt.apply valueDefined else valueDefined;
in opt //
{ value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;