Continue building nixos config even after build failure

Hello everyone,

today I tried to update my nixos system. I have a very limited internet connection at the moment so I try to match updates into periods where I have limited need of bandwith.

This usually works somewhat, most updates I get an early failure on some nixos options, which I then temporarily disable to get the build rolling. However today I had 3 packages failing, which from my understanding continues building what is currently building, stopping the build after those are done and exiting with an error code without building any of the potential other packages.

This is undesirable for my use case, because I want to come back to the building process, see that it failed, look for fixes for the failing packages and have a small rebuild incorporating those fixes. Today however I fixed one package build, ran the build again only for it to fail on the next package.

Is there a way to have nixos finish building the rest of the packages, regardless of unrelated packages failing?

I am currently using nh or nix build to rebuild my system the former more often than the latter and from my understanding those do functionally the same (in terms of building not generally) but I haven’t deeply read the source.

You might be able to use --keep-going to continue other builds as far as possible.

Ah thank you very much that seems to work. Where is that option coming from? I can see that nixos-rebuild and nh have it but nix itself doesn’t have it documented in the help/manpage.

It’s documented here Common Options - Nix 2.34.9 Reference Manual.