My phone was stuck in a boot loop too for no apparent reason. I was driving to work and suddenly the phone started rebooting. 3.5 hours later it ran out of battery. I have no idea why, but this is how I got it back to life...
I use linux ubuntu so I was able to get the developer tools:
sudo apt-get install adb android-sdk
sudo apt-get update; sudo apt-get upgrade
I also downloaded the latest image from google from:
https://dl.google.com/dl/android/aosp/hammerhead-m4b30z-factory-625c027b.zip
To recover the phone I performed the following operations from the bash shell:
1. Unlock the phone
fastboot oem unlock
me@ubuntu:~/Downloads/hammerhead-m4b30z$ fastboot oem unlock
< waiting for any device >
...
OKAY [ 47.200s]
finished. total time: 47.200s
This launches a prompt saying that it's waiting for devices. I then connect the dead phone using a regular USB cable.
The android device presents a menu saying asking if I'm sure I want to unlock the device and accept that the warranty might be void. As warranty on the Nexus 5 is void anyway, I can't see any harm in progressing.
2. Install the image file
Next I unzip the downloaded image file and cd into the folder:
me@ubuntu:~/Downloads/hammerhead-m4b30z$ ll
total 609328
drwxr-x--- 2 me me 4096 Dec 7 2016 ./
drwxr-xr-x 4 me me 4096 Oct 21 16:20 ../
-rw-r----- 1 me me 3199188 Dec 7 2016 bootloader-hammerhead-hhz20h.img
-rw-r----- 1 me me 974 Dec 7 2016 flash-all.bat
-rwxr-x--x 1 me me 845 Dec 7 2016 flash-all.sh*
-rwxr-x--x 1 me me 798 Dec 7 2016 flash-base.s
-rw-r----- 1 me me 574089971 Dec 7 2016 image-hammerhead-m4b30z.zip
-rw-r----- 1 me me 46581248 Dec 7 2016 radio-hammerhead-m8974a-2.0.50.2.30.img
As the phone is unlocked, I can issue the flash command from here:
sh flash-all.sh
As the script executes I see the following messages:
me@ubuntu:~/Downloads/hammerhead-m4b30z$ sh flash-all.sh
target reported max download size of 1073741824 bytes
sending 'bootloader' (3124 KB)...
OKAY [ 0.291s]
writing 'bootloader'...
OKAY [ 0.516s]
finished. total time: 0.807s
rebooting into bootloader...
OKAY [ 0.062s]
finished. total time: 0.112s
target reported max download size of 1073741824 bytes
sending 'radio' (45489 KB)...
OKAY [ 1.547s]
writing 'radio'...
OKAY [ 3.123s]
finished. total time: 4.670s
rebooting into bootloader...
OKAY [ 0.000s]
finished. total time: 0.050s
target reported max download size of 1073741824 bytes
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
archive does not contain 'vendor.img'
wiping userdata...
Creating filesystem with parameters:
Size: 13725835264
Block size: 4096
Blocks per group: 32768
Inodes per group: 8144
Inode size: 256
Journal blocks: 32768
Label:
Blocks: 3351034
Block groups: 103
Reserved block group size: 823
Created filesystem with 11/838832 inodes and 93654/3351034 blocks
wiping cache...
Creating filesystem with parameters:
Size: 734003200
Block size: 4096
Blocks per group: 32768
Inodes per group: 7472
Inode size: 256
Journal blocks: 2800
Label:
Blocks: 179200
Block groups: 6
Reserved block group size: 47
Created filesystem with 11/44832 inodes and 5813/179200 blocks
--------------------------------------------
Bootloader Version...: HHZ20h
Baseband Version.....: M8974A-2.0.50.2.30
Serial Number........: 02c6bc76215fcd2d
--------------------------------------------
checking product...
OKAY [ 0.100s]
checking version-bootloader...
OKAY [ 0.100s]
checking version-baseband...
OKAY [ 0.100s]
sending 'boot' (9156 KB)...
OKAY [ 0.500s]
writing 'boot'...
OKAY [ 0.781s]
sending 'recovery' (10014 KB)...
OKAY [ 0.569s]
writing 'recovery'...
OKAY [ 0.824s]
erasing 'system'...
OKAY [ 1.297s]
sending 'system' (1020657 KB)...
OKAY [ 32.164s]
writing 'system'...
OKAY [ 69.195s]
erasing 'userdata'...
OKAY [ 7.820s]
sending 'userdata' (137318 KB)...
OKAY [ 4.511s]
writing 'userdata'...
OKAY [ 9.175s]
erasing 'cache'...
OKAY [ 0.628s]
sending 'cache' (13348 KB)...
OKAY [ 0.630s]
writing 'cache'...
OKAY [ 1.064s]
rebooting...
finished. total time: 130.023s
3. Welcome To Android instructions that you see on a new device.
Now it works.