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

WIP: Move printing of warnings out of nix-evaluation #23592

Conversation

moretea
Copy link
Contributor

@moretea moretea commented Mar 7, 2017

Second part of #22096 (comment)

Motivation for this change

Warnings generated by the module system are currently printed to stdout during nix-instantiate. The problem with this is that nix-build typically generates quite a lot of output, and the end user might miss
the warnings that are generated by nix.

To make these warnings more visible, this PR proposes to gather the warnings, and write them to $out/warnings.json and $out/warnings.txt.raw. Note that $out in this context "is a" /run/current-system

$out/warnings.json will be machine readable; therefore it could be used in e.g. nixops directly.

$out/warnings.txt.raw contains a stream that can be send to stderr directly to print the warnings as they would have been printed by builtins.trace in the nix-instantiate phase.

TODO
  • Add a --skip-module-warnings flag to switch-to-configuration.pl to skip printing the
    warnings.
  • Make nixos-build print this message, then run the activation script
    with --skip-module-warnings.
  • Create a PR for NixOps to list warnings for machines.
DISCUSSION POINTS
  • Make it this configureable using an env variable.
    Some people might prefer to have the warnings up front, before
    nix-build happens.

Warnings generated by the module system are currently printed to stdout
during nix-instantiate. The problem with this is that nix-build
typically generates quite a lot of output, and the end user might miss
the warnings that are generated by nix.

To make these warnings more visible, this commit gathers the warnings,
writes them to $out/warnings.json and $out/warnings.txt.raw.

$out/warnings.json will be machine readable; therefore it could be used
in e.g. nixops directly.

$out/warnings.txt.raw contains a stream that can be send to stderr
directly to print the warnings as they would have been printed by
`builtins.trace` in the nix-instantiate phase.

TODO:

- Add a `--skip-module-warnings` flag to `switch-to-configuration.pl` to skip printing the
  warnings.
- Make nixos-build print this message, then run the activation script
  with `--skip-module-warnings`.
- Create a PR for NixOps to list warnings for machines.

DISCUSSION POINTS

- Make it this configureable using an env variable.
  Some people might prefer to have the warnings up front, before
  nix-build happens.
@mention-bot
Copy link

@moretea, thanks for your PR! By analyzing the history of the files in this pull request, we identified @vcunat, @edolstra and @lethalman to be potential reviewers.

@grahamc
Copy link
Member

grahamc commented Mar 8, 2017

I wonder about integrating these warnings in to the motd as well, but not sure. :) I'm liking the direction.

@moretea
Copy link
Contributor Author

moretea commented Mar 10, 2017

@grahamc interesting suggestion.
Like this?

image

I checked that PAM is not tripped if this file is missing, so this would be pretty safe to use.

Should we spam all users with this message?

@7c6f434c
Copy link
Member

Well, if you want to spam only one user, you can just add a line into shell profile…

@7c6f434c
Copy link
Member

I like this in principle, and I like the implementation, but I use mainline NixOS too little to be willing to merge.

@moretea
Copy link
Contributor Author

moretea commented Apr 30, 2017

@7c6f434c, if you'd add it to the shell profile, it would print out a message every time you'd start a new interactive shell, right? I think that is a little too much.

@7c6f434c
Copy link
Member

7c6f434c commented Apr 30, 2017 via email

@moretea
Copy link
Contributor Author

moretea commented Apr 30, 2017

@7c6f434c The main thing is that it prints the warnings when you activate your system, e.g. with nixos-rebuild switch. Would this PR be more mergeable if I would remove the MOTD?

I'll open a new PR for the MOTD addition then.

/cc @grahamc what do you think about this ;)?

@7c6f434c
Copy link
Member

My reluctance to merge is more about this being in a part of NixOS I am not going to use in my mix-and-match Nix-based system. I was just commenting on the space of natural options.

@mmahut
Copy link
Member

mmahut commented Aug 1, 2019

Any update on this pull request?

@mmahut
Copy link
Member

mmahut commented Aug 19, 2019

Closing due to lack of activity, feel free to reopen this if needed.

@mmahut mmahut closed this Aug 19, 2019
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

6 participants