git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #66407 from Infinisil/fix-option-rename

lib/modules: Use options `apply` function even if no values are defined

commit91f6a681e01da385d5d32087735ff3464aeb944f authorSilvan Mosberger <contact@infinisil.com> dateTue 27 Aug 2019, 22:06 (7 years ago) parent35c1c17de9cb24
1 file changed+8−10
lib/modules.nix+8−10
lib/modules.nix+8−10
@@ -323,16 +323,14 @@ rec {
323323 else
324324 mergeDefinitions loc opt.type defs';
325325
326− # Check whether the option is defined, and apply the ‘apply’
327− # function to the merged value. This allows options to yield a
328− # value computed from the definitions.
329− value =
330− if !res.isDefined then
331− throw "The option `${showOption loc}' is used but not defined."
332− else if opt ? apply then
333− opt.apply res.mergedValue
334− else
335− res.mergedValue;
326+
327+ # The value with a check that it is defined
328+ valueDefined = if res.isDefined then res.mergedValue else
329+ throw "The option `${showOption loc}' is used but not defined.";
330+
331+ # Apply the 'apply' function to the merged value. This allows options to
332+ # yield a value computed from the definitions
333+ value = if opt ? apply then opt.apply valueDefined else valueDefined;
336334
337335 in opt //
338336 { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;