Measure elapsed time in phases (successful or not)

Hello everyone.

I am looking to reliably measure the time spent in each phase while building a derivation. I am primarily interested in the buildPhase and checkPhase.

Additionally, I need to have such metrics even when a derivation fails to build.

I found this open issue 1. Do you have any other pointers?



The generic builder currently logs the start of each phase to Nix using a structured log message:

Currently this is only used in Nix to update the progress bar, but we could use it to infer the duration of each phase. Or change showPhaseFooter ( to emit a structured log message to $NIX_LOG_FD showing the duration. However, that won’t work if the phase fails.


I will into this, thank you @edolstra!

1 Like

nom is already using that.

1 Like