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
835 stars 24 forks source link

Trace messages are lost #128

Closed viperML closed 5 months ago

viperML commented 7 months ago

When piping both stdout and stderr to nom, nom doesn't print back the trace messages:

$ nix build --no-eval-cache /home/ayats/Documents/dotfiles#nixosConfigurations."hermes".config.system.build.toplevel

trace: nix-2.18.1 reached desired version 2.14.0
trace: warning: The option `services.avahi.nssmdns' defined in `/nix/store/kfblblk8pvjbdip1c9r6k3c2abdn4d1r-source/hosts/hermes/configuration.nix' has been renamed to `services.avahi.nssmdns4'.
$ nix build --no-eval-cache --log-format internal-json /home/ayats/Documents/dotfiles#nixosConfigurations."hermes".config.system.build.toplevel |& nom --json

Finished at 19:12:48 after 7s

Related: https://github.com/viperML/nh/issues/64

maralorn commented 7 months ago

Yes, that’s a known issue, but we need to fix it. I often go far to long without noticing certain warnings.

daniel-sampliner commented 5 months ago

I don't know what I'm doing, but I took a crack at this in 738f445082d6d5c8f96701ccd1fe1136a7a47715.

A simple example of the output:

 :; nix -L --log-format internal-json eval --raw --expr 'builtins.trace "some trace message" ""' |& ./result/bin/nom --json
trace: some trace message
┏━ 1 Traces: 
┃ trace: some trace message
┣━━━                                                            
┗━ ∑ ⚠ Exited with 1 traces reported by nix at 16:47:35 after 0s

For a more complicated example with NixOS module warnings (which is the main thing I was originally interested in fixing):

https://github.com/maralorn/nix-output-monitor/assets/54726391/67996707-50ab-4ad7-8ff3-81f33575f396

(built from this flake: https://github.com/daniel-sampliner/nix-output-monitor/blob/nixos-warning-example/flake.nix)

viperML commented 5 months ago

Github says that "video can't be plated because the file is corrupt"

daniel-sampliner commented 5 months ago

Odd. I must have used funky ffmpeg seetings since that plays fine for me on my computer. Does this work:

cast

I don't think static output does it full justice, but this is what the end results look like when building that flake:

┏━ 52 Traces: 
 ⋮ 
┃ trace: warning: nixos module warning #34
┃ trace: warning: nixos module warning #35
┃ trace: warning: nixos module warning #36
┃ trace: warning: nixos module warning #37
┃ trace: warning: nixos module warning #38
┃ trace: warning: nixos module warning #39
┃ trace: warning: nixos module warning #40
┃ trace: warning: nixos module warning #41
┃ trace: warning: nixos module warning #42
┃ trace: warning: nixos module warning #43
┃ trace: warning: nixos module warning #44
┃ trace: warning: nixos module warning #45
┃ trace: warning: nixos module warning #46
┃ trace: warning: nixos module warning #47
┃ trace: warning: nixos module warning #48
┃ trace: warning: nixos module warning #49
┃ trace: warning: nixos module warning #50
┣━ Dependency Graph:
┃    ┌─ ✔ etc-bashrc 
┃    │  ┌─ ✔ unit-dbus.service 
┃    ├─ ✔ user-units 
┃    │     ┌─ ✔ reload-container 
┃    │  ┌─ ✔ unit-container-.service 
┃    │  │              ┌─ ✔ perl-5.38.0-env ⏱ 2s
┃    │  │           ┌─ ✔ command-not-found 
┃    │  │        ┌─ ✔ system-path ⏱ 1s
┃    │  │     ┌─ ✔ dbus-1 
┃    │  │  ┌─ ✔ X-Restart-Triggers-dbus 
┃    │  ├─ ✔ unit-dbus.service 
┃    ├─ ✔ system-units 
┃ ┌─ ✔ etc 
┃ ✔ nixos-system-nixos-23.11.20231129.057f9ae 
┗━ ∑ ⏵ 0 │ ✔ 228 │ ⏸ 0 │ ↓ 0 │ ↓ 371 │ ⏸ 0 │ ⚠ Exited with 52 traces reported b…
viperML commented 5 months ago

LGTM, very cool :+1: