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 | |
parent | dbefab9cf42c09444dd2554380104096969c0728 (diff) | |
download | nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar.gz nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar.bz2 nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar.lz nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar.xz nixlib-73f32d03758a53ad1baac31795cfd99e325032f3.tar.zst nixlib-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')
-rw-r--r-- | nixos/modules/config/shells-environment.nix | 9 | ||||
-rw-r--r-- | nixos/modules/config/sysctl.nix | 2 | ||||
-rw-r--r-- | nixos/modules/misc/nixpkgs.nix | 2 |
3 files changed, 8 insertions, 5 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); diff --git a/nixos/modules/config/sysctl.nix b/nixos/modules/config/sysctl.nix index 6b52fd38fdec..a825144e466b 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 diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix index 9eba728c3390..dfbd98bf6ee5 100644 --- a/nixos/modules/misc/nixpkgs.nix +++ b/nixos/modules/misc/nixpkgs.nix @@ -26,7 +26,7 @@ let configType = mkOptionType { name = "nixpkgs config"; check = traceValIfNot isConfig; - merge = fold mergeConfig {}; + merge = args: fold mergeConfig {}; }; in |