summary refs log tree commit diff
path: root/lib/options.nix
diff options
context:
space:
mode:
authordanbst <abcz2.uprola@gmail.com>2019-06-05 02:50:49 +0300
committerdanbst <abcz2.uprola@gmail.com>2019-06-05 03:10:57 +0300
commitbfb6ef1d59338e07f94f395cc56c98c116987c3d (patch)
treedfa3edd51732297eb11d201617ebf31f73231e37 /lib/options.nix
parente380ef398761206954e51426d16a328eaba27fce (diff)
downloadnixpkgs-bfb6ef1d59338e07f94f395cc56c98c116987c3d.tar
nixpkgs-bfb6ef1d59338e07f94f395cc56c98c116987c3d.tar.gz
nixpkgs-bfb6ef1d59338e07f94f395cc56c98c116987c3d.tar.bz2
nixpkgs-bfb6ef1d59338e07f94f395cc56c98c116987c3d.tar.lz
nixpkgs-bfb6ef1d59338e07f94f395cc56c98c116987c3d.tar.xz
nixpkgs-bfb6ef1d59338e07f94f395cc56c98c116987c3d.tar.zst
nixpkgs-bfb6ef1d59338e07f94f395cc56c98c116987c3d.zip
module system: prettify a bit error when unique option defined twice
The error can be reproduced like:
```
$ nix-instantiate ./nixos -A system --arg configuration '
  { fileSystems."/".device = "nodev";
    boot.loader.grub.devices = [ "nodev" ];
    containers.t.config.imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ];
  }'
```

Previously error was:
```
error: The unique option `containers.t.networking.hostName' is defined multiple times, in `/nix/var/nix/profiles/per-user/root/channels/nixpkgs/nixos/modules/virtualisation/amazon-image.nix' and `module at /home/danbst/dev/nixpkgs/nixos/modules/virtualisation/containers.nix:470'.
(use '--show-trace' to show detailed location information)
```

Now it is:
```
error: The unique option `containers.t.networking.hostName' is defined multiple times, in:
 - /nix/var/nix/profiles/per-user/root/channels/nixpkgs/nixos/modules/virtualisation/amazon-image.nix
 - module at /home/danbst/dev/nixpkgs/nixos/modules/virtualisation/containers.nix:470.
(use '--show-trace' to show detailed location information)
```

Related: https://github.com/NixOS/nixpkgs/issues/15747
Diffstat (limited to 'lib/options.nix')
-rw-r--r--lib/options.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/options.nix b/lib/options.nix
index a16a980398d..d2eae3ae3a9 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -101,7 +101,7 @@ rec {
   mergeOneOption = loc: defs:
     if defs == [] then abort "This case should never happen."
     else if length defs != 1 then
-      throw "The unique option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}."
+      throw "The unique option `${showOption loc}' is defined multiple times, in:\n - ${concatStringsSep "\n - " (getFiles defs)}."
     else (head defs).value;
 
   /* "Merge" option definitions by checking that they all have the same value. */