summary refs log tree commit diff
path: root/lib/options.nix
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2020-09-15 20:30:48 +0200
committerSilvan Mosberger <contact@infinisil.com>2020-09-15 21:01:07 +0200
commit6e7bc2c6c90335e7bb7d7ca8cef77c58f0e37444 (patch)
tree1279c39812fa34607299e3c567921b225112757a /lib/options.nix
parentb3810166c7dc5c75a5961e9c92726361a1ffc316 (diff)
downloadnixpkgs-6e7bc2c6c90335e7bb7d7ca8cef77c58f0e37444.tar
nixpkgs-6e7bc2c6c90335e7bb7d7ca8cef77c58f0e37444.tar.gz
nixpkgs-6e7bc2c6c90335e7bb7d7ca8cef77c58f0e37444.tar.bz2
nixpkgs-6e7bc2c6c90335e7bb7d7ca8cef77c58f0e37444.tar.lz
nixpkgs-6e7bc2c6c90335e7bb7d7ca8cef77c58f0e37444.tar.xz
nixpkgs-6e7bc2c6c90335e7bb7d7ca8cef77c58f0e37444.tar.zst
nixpkgs-6e7bc2c6c90335e7bb7d7ca8cef77c58f0e37444.zip
lib/options: Fix mergeEqualOption for singular functions
Previously it would error out for a single function definition
Diffstat (limited to 'lib/options.nix')
-rw-r--r--lib/options.nix4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/options.nix b/lib/options.nix
index 38f4f1329f2..0494a597ab8 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -107,6 +107,10 @@ rec {
   /* "Merge" option definitions by checking that they all have the same value. */
   mergeEqualOption = loc: defs:
     if defs == [] then abort "This case should never happen."
+    # Return early if we only have one element
+    # This also makes it work for functions, because the foldl' below would try
+    # to compare the first element with itself, which is false for functions
+    else if length defs == 1 then (elemAt defs 0).value
     else foldl' (val: def:
       if def.value != val then
         throw "The option `${showOption loc}' has conflicting definitions, in ${showFiles (getFiles defs)}."