summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/options.nix9
-rw-r--r--lib/types.nix2
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/options.nix b/lib/options.nix
index a30397c7216..bfc5b5fa2ae 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -65,6 +65,15 @@ rec {
       throw "The unique option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}."
     else (head defs).value;
 
+  /* "Merge" option definitions by checking that they all have the same value. */
+  mergeEqualOption = loc: defs:
+    if defs == [] then abort "This case should never happen."
+    else fold (def: val:
+      if def.value != val then
+        throw "The option `${showOption loc}' has conflicting definitions, in ${showFiles (getFiles defs)}."
+      else
+        val) (head defs).value defs;
+
   getValues = map (x: x.value);
   getFiles = map (x: x.file);
 
diff --git a/lib/types.nix b/lib/types.nix
index f22c7661634..0a54a5598f1 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -54,7 +54,7 @@ rec {
     bool = mkOptionType {
       name = "boolean";
       check = isBool;
-      merge = loc: fold (x: y: x.value || y) false;
+      merge = mergeEqualOption;
     };
 
     int = mkOptionType {