summary refs log tree commit diff
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorSilvan Mosberger <infinisil@icloud.com>2019-08-10 00:04:07 +0200
committerSilvan Mosberger <infinisil@icloud.com>2019-08-10 00:56:56 +0200
commitde9cb249389f303ccd1ae3c6a1265e6ca8a3f146 (patch)
tree193645f02682fd7423566eab634a5e62463526d2 /lib/modules.nix
parent3cde54ceb990d2370bd24191a86eebe91590a75e (diff)
downloadnixpkgs-de9cb249389f303ccd1ae3c6a1265e6ca8a3f146.tar
nixpkgs-de9cb249389f303ccd1ae3c6a1265e6ca8a3f146.tar.gz
nixpkgs-de9cb249389f303ccd1ae3c6a1265e6ca8a3f146.tar.bz2
nixpkgs-de9cb249389f303ccd1ae3c6a1265e6ca8a3f146.tar.lz
nixpkgs-de9cb249389f303ccd1ae3c6a1265e6ca8a3f146.tar.xz
nixpkgs-de9cb249389f303ccd1ae3c6a1265e6ca8a3f146.tar.zst
nixpkgs-de9cb249389f303ccd1ae3c6a1265e6ca8a3f146.zip
lib/modules: Use options `apply` function even if no values are defined
This allows `apply` functions to return a valid value if they completely
ignore their argument, which is the case for the option renaming
functions like `mkAliasOptionModule`. Therefore this solves issue #63693
Diffstat (limited to 'lib/modules.nix')
-rw-r--r--lib/modules.nix18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 0869eae1982..c3c903c1dfa 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;