I have read that it would be difficult to stop rocks with nuclear bombs. It is not practical to fly the bomb at the thing and detonate it the moment they are close, with a proximity fuse. Large, heavy objects often survived above ground nuclear explosions intact.
I think no matter what technique you use, you have to land on the rock and then deploy something. If you have plenty of time -- several years let us say -- might as well deploy a bucket of paint or a small laser as a nuclear bomb. It does not take much to change the trajectory. Most of these objects are not big. I think the big ones are all detected and accounted for. The acute danger is one showing up weeks or months before impact. Perhaps a "hail Mary" nuclear bomb might stop it. I think you would have to land on it, dig a hole, and then use the bomb. That would make the rock resemble a nuclear bomb powered "Orion" rocket. Landing and deploying a bomb in this manner sounds impossible without a human crew, but the robot explorers on Mars have remarkable abilities. Perhaps in a generation they will be capable of this. - Jed

