diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-30 14:21:41 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-30 14:57:43 +0100 |
commit | 800f9c203728ee84d50181af6fa34ac9e5c04e73 (patch) | |
tree | 69192ea9020cffb5a6a51557f17105ec10d76bb5 /nixos/modules/config | |
parent | 4680af6a9334297885a96ba464d58316587a87fd (diff) |
Show correct position info for errors in submodules
E.g. The unique option `fileSystems./.device' is defined multiple times, in `/etc/nixos/configuration.nix' and `/etc/nixos/foo.nix'. This requires passing file/value tuples to the merge functions.
Diffstat (limited to 'nixos/modules/config')
-rw-r--r-- | nixos/modules/config/shells-environment.nix | 20 | ||||
-rw-r--r-- | nixos/modules/config/sysctl.nix | 2 |
2 files changed, 12 insertions, 10 deletions
diff --git a/nixos/modules/config/shells-environment.nix b/nixos/modules/config/shells-environment.nix index 36f8549af8e29..e3fbdd7aaec1b 100644 --- a/nixos/modules/config/shells-environment.nix +++ b/nixos/modules/config/shells-environment.nix @@ -25,15 +25,17 @@ in ''; type = types.attrsOf (mkOptionType { name = "a string or a list of strings"; - merge = args: xs: - let xs' = filterOverrides xs; in - if isList (head xs') then concatLists xs' - 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'; + merge = loc: defs: + let + defs' = filterOverrides defs; + res = (head defs').value; + in + if isList res then concatLists (getValues defs') + else if builtins.lessThan 1 (length defs') then + throw "The option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}." + else if !builtins.isString res then + throw "The option `${showOption loc}' does not have a string value, in ${showFiles (getFiles defs)}." + else res; }); 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 a825144e466b9..31441bad61579 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 = args: xs: last xs; # FIXME: hacky way to allow overriding in configuration.nix. + merge = args: defs: (last defs).value; # FIXME: hacky way to allow overriding in configuration.nix. }; in |