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

aliases.nix: always include attr name in error msg #101210

Closed

Conversation

9999years
Copy link
Contributor

In pkgs/top-level/aliases.nix, throw was used to make packages that were removed error with a more useful message than attribute 'foobar' missing, at <location>.

However, if the error message doesn't include the package's attribute name, it can be difficult to determine what caused it. For example, here's what building a configuration that referenced ytop looked like recently (see #101098):

$ nixos-rebuild switch
building Nix...
building the system configuration...
error: Abandoned by upstream. Consider switching to bottom instead
(use '--show-trace' to show detailed location information)

Therefore, we modify string values in aliases.nix to prefix Attribute foobar in <nixpkgs> has been removed to the reason message. This makes the removed reasons a bit shorter and provides a place to unilaterally improve these error messages in the future, rather than with one-off changes or large sets of manual fixes.

Built/tested on NixOS.

aliases.nix: errors should include package names

In `pkgs/top-level/aliases.nix`, `throw` was used to make packages that
were removed error with a more useful message than "attribute 'foobar'
missing, at <location>".

However, if the error message doesn't include the package's attribute
name, it can be difficult to determine what caused it. For example,
here's what building a configuration that referenced `ytop` looked like
recently (see NixOS#101098):

```
$ nixos-rebuild switch
building Nix...
building the system configuration...
error: Abandoned by upstream. Consider switching to bottom instead
(use '--show-trace' to show detailed location information)
```

Therefore, we modify string values in `aliases.nix` to prefix `Attribute
foobar in <nixpkgs> has been removed` to the reason message. This makes
the removed reasons a bit shorter and provides a place to unilaterally
improve these error messages in the future, rather than with one-off
changes or large sets of manual fixes.
# avoid confusing errors:
# https://github.com/NixOS/nixpkgs/pull/101098
if lib.isString alias then
throw "Attribute ${n} in <nixpkgs> has been removed; ${alias}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<nixpkgs> might not always exist (e.g. in a flakes-based system). Maybe just s/<nixpkgs>/Nixpkgs/?

@SuperSandro2000
Copy link
Member

I think this would be a great addition but we also would need more people on agreeing if we want this because otherwise @9999years is fixing merge conflicts forever.

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

3 participants