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/shells-environment.nix | |
parent | 4680af6a9334297885a96ba464d58316587a87fd (diff) | |
download | nixpkgs-800f9c203728ee84d50181af6fa34ac9e5c04e73.tar nixpkgs-800f9c203728ee84d50181af6fa34ac9e5c04e73.tar.gz nixpkgs-800f9c203728ee84d50181af6fa34ac9e5c04e73.tar.bz2 nixpkgs-800f9c203728ee84d50181af6fa34ac9e5c04e73.tar.lz nixpkgs-800f9c203728ee84d50181af6fa34ac9e5c04e73.tar.xz nixpkgs-800f9c203728ee84d50181af6fa34ac9e5c04e73.tar.zst nixpkgs-800f9c203728ee84d50181af6fa34ac9e5c04e73.zip |
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/shells-environment.nix')
-rw-r--r-- | nixos/modules/config/shells-environment.nix | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/nixos/modules/config/shells-environment.nix b/nixos/modules/config/shells-environment.nix index 36f8549af8e..e3fbdd7aaec 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); }; |