git.iko.soy/typeable/nixpkgs
on master help sign in
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

commitbfb6ef1d59338e07f94f395cc56c98c116987c3d authordanbst <abcz2.uprola@gmail.com> dateWed 5 Jun 2019, 02:50 (7 years ago) parente380ef3
1 file changed+1−1
lib/options.nix+1−1
lib/options.nix+1−1
@@ -101,7 +101,7 @@ rec {
101101 mergeOneOption = loc: defs:
102102 if defs == [] then abort "This case should never happen."
103103 else if length defs != 1 then
104− throw "The unique option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}."
104+ throw "The unique option `${showOption loc}' is defined multiple times, in:\n - ${concatStringsSep "\n - " (getFiles defs)}."
105105 else (head defs).value;
106106
107107 /* "Merge" option definitions by checking that they all have the same value. */