summary refs log tree commit diff
path: root/lib/options.nix
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2023-02-09 07:38:40 +0000
committerDomen Kožar <domen@dev.si>2023-02-09 08:24:12 +0000
commitfe734efc9c2c0a42b9c34dfd6280d82558744a06 (patch)
tree13c70ab46a2f6ed6c94e210e8af1f78e454bf60c /lib/options.nix
parentb3cc29c288b6ac5e2fa71477cabb2d088f568001 (diff)
downloadnixpkgs-fe734efc9c2c0a42b9c34dfd6280d82558744a06.tar
nixpkgs-fe734efc9c2c0a42b9c34dfd6280d82558744a06.tar.gz
nixpkgs-fe734efc9c2c0a42b9c34dfd6280d82558744a06.tar.bz2
nixpkgs-fe734efc9c2c0a42b9c34dfd6280d82558744a06.tar.lz
nixpkgs-fe734efc9c2c0a42b9c34dfd6280d82558744a06.tar.xz
nixpkgs-fe734efc9c2c0a42b9c34dfd6280d82558744a06.tar.zst
nixpkgs-fe734efc9c2c0a42b9c34dfd6280d82558744a06.zip
types: suggest how to resolve the conflict
Diffstat (limited to 'lib/options.nix')
-rw-r--r--lib/options.nix7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/options.nix b/lib/options.nix
index 22eb6c2eeb1..5e8f4ca4bb9 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -36,6 +36,9 @@ let
   inherit (lib.types)
     mkOptionType
     ;
+  prioritySuggestion = ''
+   Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.
+  '';
 in
 rec {
 
@@ -184,7 +187,7 @@ rec {
     if length defs == 1
     then (head defs).value
     else assert length defs > 1;
-      throw "The option `${showOption loc}' is defined multiple times while it's expected to be unique.\n${message}\nDefinition values:${showDefs defs}";
+      throw "The option `${showOption loc}' is defined multiple times while it's expected to be unique.\n${message}\nDefinition values:${showDefs defs}\n${prioritySuggestion}";
 
   /* "Merge" option definitions by checking that they all have the same value. */
   mergeEqualOption = loc: defs:
@@ -195,7 +198,7 @@ rec {
     else if length defs == 1 then (head defs).value
     else (foldl' (first: def:
       if def.value != first.value then
-        throw "The option `${showOption loc}' has conflicting definition values:${showDefs [ first def ]}"
+        throw "The option `${showOption loc}' has conflicting definition values:${showDefs [ first def ]}\n${prioritySuggestion}"
       else
         first) (head defs) (tail defs)).value;