So I've been facing this problem during all weekend, and I'm just about to call my Nexus 5 officially dead.
Same symptoms as others. I installed Android 5.1.1 a few days back. The phone started to reboot once and again. Since I had the "lock button issue" before, I knew this time wasn't the same thing. The system starts and tries to optimize the apps due an abnormal shutdown. After trying to optimize 80,120, or any random number of apps, it restarts again in an endless loop.
I have tried all: I wiped the cache partition, once and again. I tried to go back flashing to a previous android version. Didn't work. I tried installing cyanogen mod, and still facing the same issue.
I'm not sure if replacing the battery will do the trick, but I suspect another kind of hardware damage in my device.
If anyone has the same issues as mine, drop me a message and let's see if we can came up with a solution.
Thanks,