Any way to programmatically track progress of nixos-rebluid?

Hi!

I’m writing a Python API which interacts with NixOS and allows performing system administrative tasks from the mobile app.

While I can start the nixos-rebuild switch and check whether the process has exited, I would like to somehow get machine-readable status of the rebuild to show it in app in real-time. For example, in percents, how much derivations has been downloaded/built, or at least what’s the current stage of the rebuild. What are the options to do this, if any?

I’ve checked out the graphical NixOS installer, and it turned out that it doesn’t track the progress of nix build process (just jumps from 46% to 100% when installation is done).

1 Like

While it is not nixos-rebuild specific, @maralorn has a really nice program that parses the output of nix-build to track the build progress:

I really like nix-output-monitor, and recommend it to anyone who frequently uses nix-build on the cli.

4 Likes