This is used by the Hydra queue runner, but since it may also be useful for the C++ rewrite of nix-push, I'm putting it here.