I think I have the same use case and solve this with
nix.settings = {
connect-timeout = 3; # optional
fallback = true;
}
See the nix.conf - Nix 2.29.1 Reference Manual:
Maybe give it a try …
You also can try this beforehand at/with your nh os switch command. – I don’t know the details and only will mention, that you do not have to add the substituter https://cache.nixos.org because this is the default and you only append the other subsituters (to this default) … #AFAIK
And also FYI: this is how I add my personal substituter + cache (powered by ncps ATM):
nix.settings = {
#substituters = lib.mkBefore [ "http://$MYNCACHE:8501" ];
substituters = [ "http://$MYNCACHE:8501?priority=1" ];
trusted-public-keys = [ "$MYNCACHE:T[…]=" ];
trusted-substituters = [ "http://$MYNCACHE:8501" ];
};
KR
Update: Bug: The build fails if a build machine/cache is offline · Issue #3514 · NixOS/nix · GitHub may be relevant here …