Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NixOS module system: improve one of error messages #62712

Merged
merged 2 commits into from Jun 13, 2019

Conversation

danbst
Copy link
Contributor

@danbst danbst commented Jun 5, 2019

Motivation for this change

Partially helps with #15747

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 `<unknown-file>'.
    (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)

What do you think? Is it clearer now?

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: NixOS#15747
See NixOS#15747. Previously this module was called `<unknown-file>`
in error messages, now it is called a bit more close to real:
```
module at /home/danbst/dev/nixpkgs/nixos/modules/virtualisation/containers.nix:470
```
@teto
Copy link
Member

teto commented Jun 5, 2019

that's cool ! I have many similar issues where it can't pinpoint the issue. I just need to add _file = "module at ${__curPos.file}:${toString __curPos.line}"; good to know.

@danbst danbst merged commit e718eb6 into NixOS:master Jun 13, 2019
@danbst danbst deleted the module-conflict-naming branch June 13, 2019 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants