diff options
author | Silvan Mosberger <contact@infinisil.com> | 2019-08-27 22:06:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-27 22:06:23 +0200 |
commit | 91f6a681e01da385d5d32087735ff3464aeb944f (patch) | |
tree | 29a4e5187e3fcb25c2f117d9ca489f7dbd12db39 /lib | |
parent | 35c1c170d7dc49bf3f878a2170be487c5d27c8b1 (diff) | |
parent | de9cb249389f303ccd1ae3c6a1265e6ca8a3f146 (diff) |
Merge pull request #66407 from Infinisil/fix-option-rename
lib/modules: Use options `apply` function even if no values are defined
Diffstat (limited to 'lib')
-rw-r--r-- | lib/modules.nix | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/modules.nix b/lib/modules.nix index 0869eae1982b..c3c903c1dfa8 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -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; |