From 998a9c17078bfb328a1329494f082dfa13f97d9e Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Tue, 10 Aug 2021 19:54:32 +0200 Subject: [PATCH] lib/options: Better mergeEqualOption error for uncomparable types For an option definition that uses `lib.options.mergeEqualOption` underneath, like `types.anything`, an error is thrown when multiple functions are assigned, indicating that functions can't be compared for equivalence: error: The option `test' has conflicting definition values: - In `xxx': - In `xxx': (use '--show-trace' to show detailed location information) However, the error message didn't use the correct files. While above error indicates that both definitions are in the xxx file, that's in fact not true. Above error was generated with options.test = lib.mkOption { type = lib.types.anything; }; imports = [ { _file = "yyy"; test = y: y; } { _file = "xxx"; test = x: x; } ]; With this change, the error uses the correct file locations: error: The option `test' has conflicting definition values: - In `xxx': - In `yyy': (use '--show-trace' to show detailed location information) --- lib/options.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/options.nix b/lib/options.nix index 87cd8b797969..204c86df9f51 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -11,6 +11,7 @@ let filter foldl' head + tail isAttrs isBool isDerivation @@ -144,7 +145,7 @@ rec { if def.value != first.value then throw "The option `${showOption loc}' has conflicting definition values:${showDefs [ first def ]}" else - first) (head defs) defs).value; + first) (head defs) (tail defs)).value; /* Extracts values of all "value" keys of the given list.