maralorn / nix-output-monitor

Pipe your nix-build output through the nix-output-monitor a.k.a nom to get additional information while building.
GNU Affero General Public License v3.0
841 stars 24 forks source link

Add options to control how logs are printed #59

Open maralorn opened 1 year ago

maralorn commented 1 year ago

We can add an option called --log-lines with the semantic

infinity: print everything, continuous log, default 0: don‘t print logs n: always show n last lines of log, clearing everything above and hiding log, when build has finished, could be default for shell and other ambient commands.

30350n commented 4 months ago

Hi! I'm currently trying to integrate nom into my nixos rebuild script and was looking for something like this. Ideally I'd want to pipe any build output to a log file and only show the nice nom output. Redirection is already easily possible by using tee (as discussed in #89) but I wasn't able to stop nom from printing the logs yet. (I've tried using grep with the unicode box drawing chars, but it doesn't seem to handle escape codes nicely ^^).

I understand that implementing this with an option and a variable number of log lines etc. is probably not super trivial and I sadly don't think I'm able to implement this myself, because I'm not really used to functional programming much.

If this was a procedural program, I'd expect to be able to comment out a couple of lines (that are responsible for piping through the logs) somewhere. (This way I could create a patch for this and add it as a package overlay). Like I said, I'm not super familiar with Haskell, but I'd kinda expect this to work similarily.

So could you maybe direct me to the section in the code were the output redirection happens? Thanks a lot!

(Related issues: #89, #99, #126 would also be a nice to have for this).

maralorn commented 4 months ago

For a quick an dirty solution you can set this variable to the empty list.

https://github.com/maralorn/nix-output-monitor/blob/5cc29ee7cc056bff2aac639e89d3389b77d52f7a/lib/NOM/IO.hs#L92

30350n commented 4 months ago

Perfect, this is exactly what I was looking for, thanks a ton! ❤️

30350n commented 4 months ago

If anyone's interested, here's an override which implements this.