Google started posting Android 5.1 factory images on the developer page and now you can bring your Nexus back from the brink of disaster. Google didn’t push images for all of the devices yet, but the list is getting bigger and bigger.
As long as you have access to fastbot, you will be able to flash the system image without problems. You will also find updated binaries with the drivers needed to run ROMs on the devices you update. In order to flash a factory image, you will need an unlocked bootloader.
You can download the image for your device from the list below: