Nix-build sending a large chunk of output to stderr?

I’m working with shell processes in Haskell and I’m hitting such a weird case when I make it run nix-build. The output of the process is collected with typed-process and most of the output is going to the stderr handle. The only part of the build that seems to be redirected to stdout is when the derivation has finally been built and nix outputs the store path.

Short example

received: ERROR:these derivations will be built:
received: ERROR:  /nix/store/8hdn2gzqi9x6945189myvwxqiba7c965-donnabot-service-
received: ERROR:building '/nix/store/8hdn2gzqi9x6945189myvwxqiba7c965-donnabot-service-'...
received: ERROR:setupCompilerEnvironmentPhase
received: ERROR:Build with /nix/store/chrd8j878hll3p0ybvqy9g9w1knmzab8-ghc-8.8.4.
received: ERROR:unpacking sources
received: ERROR:unpacking source archive /nix/store/fzlqd5d51vvap46bybi742fld77rk1zl-source

finally the last line is not stderr

received: ERROR:patching script interpreter paths in /nix/store/1s65m6ci7zdj04gljrfbdyv9cswjji2d-donnabot-service-
received: INFO:/nix/store/1s65m6ci7zdj04gljrfbdyv9cswjji2d-donnabot-service-

does anyone know why this is the case? why would Haskell pick this up as stderr?

All these messages really are being sent to stderr by nix-build. This is because these messages are “unimportant” in the sense that as long as everything built ok, these messages can be thrown away.

It also allows you to use the output of the command in further shell scripting:

$ nix-store --query --requisites $(nix-build default.nix)

If nix-build sent all it’s build output to stdout, this trick wouldn’t work

1 Like

ahh I see. Thank you for clearing that.