diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-28 19:48:30 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-28 22:45:57 +0100 |
commit | 73f32d03758a53ad1baac31795cfd99e325032f3 (patch) | |
tree | 8df21c7319e758a85a4916890714b0d90c631a67 /nixos/modules/config | |
parent | dbefab9cf42c09444dd2554380104096969c0728 (diff) | |
download | nixpkgs-73f32d03758a53ad1baac31795cfd99e325032f3.tar nixpkgs-73f32d03758a53ad1baac31795cfd99e325032f3.tar.gz nixpkgs-73f32d03758a53ad1baac31795cfd99e325032f3.tar.bz2 nixpkgs-73f32d03758a53ad1baac31795cfd99e325032f3.tar.lz nixpkgs-73f32d03758a53ad1baac31795cfd99e325032f3.tar.xz nixpkgs-73f32d03758a53ad1baac31795cfd99e325032f3.tar.zst nixpkgs-73f32d03758a53ad1baac31795cfd99e325032f3.zip |
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')
-rw-r--r-- | nixos/modules/config/shells-environment.nix | 9 | ||||
-rw-r--r-- | nixos/modules/config/sysctl.nix | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/nixos/modules/config/shells-environment.nix b/nixos/modules/config/shells-environment.nix index 4c40f33532f..36f8549af8e 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); diff --git a/nixos/modules/config/sysctl.nix b/nixos/modules/config/sysctl.nix index 6b52fd38fde..a825144e466 100644 --- a/nixos/modules/config/sysctl.nix +++ b/nixos/modules/config/sysctl.nix @@ -7,7 +7,7 @@ let sysctlOption = mkOptionType { name = "sysctl option value"; check = x: builtins.isBool x || builtins.isString x || builtins.isInt x; - merge = xs: last xs; # FIXME: hacky way to allow overriding in configuration.nix. + merge = args: xs: last xs; # FIXME: hacky way to allow overriding in configuration.nix. }; in |