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