summaryrefslogtreecommitdiffstats
path: root/nixos/modules/config/shells-environment.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-28 19:48:30 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-28 22:45:57 +0100
commit73f32d03758a53ad1baac31795cfd99e325032f3 (patch)
tree8df21c7319e758a85a4916890714b0d90c631a67 /nixos/modules/config/shells-environment.nix
parentdbefab9cf42c09444dd2554380104096969c0728 (diff)
Show precise error messages in option merge failures
For instance, if time.timeZone is defined multiple times, you now get the error message: error: user-thrown exception: The unique option `time.timeZone' is defined multiple times, in `/etc/nixos/configurations/misc/eelco/x11vnc.nix' and `/etc/nixos/configuration.nix'. while previously you got: error: user-thrown exception: Multiple definitions of string. Only one is allowed for this option. and only an inspection of the stack trace gave a clue as to what option caused the problem.
Diffstat (limited to 'nixos/modules/config/shells-environment.nix')
-rw-r--r--nixos/modules/config/shells-environment.nix9
1 files changed, 6 insertions, 3 deletions
diff --git a/nixos/modules/config/shells-environment.nix b/nixos/modules/config/shells-environment.nix
index 4c40f33532f8..36f8549af8e2 100644
--- a/nixos/modules/config/shells-environment.nix
+++ b/nixos/modules/config/shells-environment.nix
@@ -25,11 +25,14 @@ in
'';
type = types.attrsOf (mkOptionType {
name = "a string or a list of strings";
- merge = xs:
+ merge = args: xs:
let xs' = filterOverrides xs; in
if isList (head xs') then concatLists xs'
- else if builtins.lessThan 1 (length xs') then abort "variable in ‘environment.variables’ has multiple values"
- else if !builtins.isString (head xs') then abort "variable in ‘environment.variables’ does not have a string value"
+ else if builtins.lessThan 1 (length xs') then
+ # Don't show location info here, since it's too general.
+ throw "The option `${showOption args.prefix}' is defined multiple times."
+ else if !builtins.isString (head xs') then
+ throw "The option `${showOption args.prefix}' does not have a string value."
else head xs';
});
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);