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

ninja: pipe ninja output through cat in hooks #149810

Merged
merged 1 commit into from
Dec 9, 2021

Conversation

pennae
Copy link
Contributor

@pennae pennae commented Dec 9, 2021

Motivation for this change

it would be nice to have progress output from builds using ninja. (ninja progress reports are hidden because ninja never really writes out full lines, it keeps overwriting the same line)

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

ninja build progress output is not line-base, it overwrites the same
line over and over again with its progress reporting. nix is line-based
though, so ninja-based builds have their progress hidden. pipe ninja
output through cat to avoid this.
@lovesegfault
Copy link
Member

Would using -v instead suffice?

@pennae
Copy link
Contributor Author

pennae commented Dec 9, 2021

-v would work, but it also prints the full command lines (it might make sense to set that when NIX_DEBUG is set though). another workaround we've seen was setting TERM=dumb, but adding to the process environment has more potential for side-effects than going through cat.

Copy link
Member

@dasJ dasJ left a comment

Choose a reason for hiding this comment

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

Code looks good, I didn't test this but I don't think this should be able to break anything ;)

@pennae
Copy link
Contributor Author

pennae commented Dec 9, 2021

systemd and glib built fine with it, after those we stopped checking which derivations in the test build used ninja :D

@dasJ dasJ merged commit 5f136ae into NixOS:staging Dec 9, 2021
@pennae pennae deleted the ninja-progress branch December 9, 2021 11:36
@milahu
Copy link
Contributor

milahu commented Feb 5, 2022

alternative solution:

export TERM=dumb
ninja

@nagy
Copy link
Member

nagy commented Mar 29, 2022

I think I have found a problem with this. The piping into cat ignores the exitcode of ninja. So I built this: nagy@ff0db14

The PoC is in the commit message. I have not found a package where this is a problem, but if we ever rely on the ninja*Phasees alone to build a package, then errors may be ignored.

Does this need a pull request?

@pennae
Copy link
Contributor Author

pennae commented Mar 29, 2022

yes please. ignoring exit codes in a builder should never happen 😳</del?

edit: after experimenting locally, probably not. stdenv does set -o pipefail so this won't affect builds within nix itself, only in nix-shell. and that's not even limited to ninja.

@nagy
Copy link
Member

nagy commented Mar 29, 2022

stdenv does set -o pipefail so this won't affect builds within nix itself

That would explain why I did not see this failing in normal package builds, thanks.

only in nix-shell. and that's not even limited to ninja.

It is a bit unfortunate, but understandable that pipefail is not set in nix-shell because this means that it can sometimes be surprising if you rely on the exitcode of any phase.

But ok, then this does not effect this code after all. Thank you for the investigation.

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.

8 participants