Merge pull request #215455 from domenkozar/module-errors

nixos: Improve module conflict error messages

authored by Domen Kožar and committed by GitHub 844a738b c257eba8

+5 -2
+5 -2
lib/options.nix
··· 36 36 inherit (lib.types) 37 37 mkOptionType 38 38 ; 39 + prioritySuggestion = '' 40 + Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions. 41 + ''; 39 42 in 40 43 rec { 41 44 ··· 184 187 if length defs == 1 185 188 then (head defs).value 186 189 else assert length defs > 1; 187 - throw "The option `${showOption loc}' is defined multiple times.\n${message}\nDefinition values:${showDefs defs}"; 190 + throw "The option `${showOption loc}' is defined multiple times while it's expected to be unique.\n${message}\nDefinition values:${showDefs defs}\n${prioritySuggestion}"; 188 191 189 192 /* "Merge" option definitions by checking that they all have the same value. */ 190 193 mergeEqualOption = loc: defs: ··· 195 198 else if length defs == 1 then (head defs).value 196 199 else (foldl' (first: def: 197 200 if def.value != first.value then 198 - throw "The option `${showOption loc}' has conflicting definition values:${showDefs [ first def ]}" 201 + throw "The option `${showOption loc}' has conflicting definition values:${showDefs [ first def ]}\n${prioritySuggestion}" 199 202 else 200 203 first) (head defs) (tail defs)).value; 201 204