[Nexus 5 Q&A, Help & Troubleshooting] Mawth:
Like many people have experienced, one day the power button on my Nexus 5 failed, and an endless cycle of bootloops began, rendering my device useless.

At this point, there are really only two options.

Option 1: Replace the power button. For me, this option is a bit beyond my soldering capabilities. And to be done properly, requires equipment (e.g., soldering stand with magnifier) that I don't have. :(

Option 2: Physically remove the offending power button (which at a minimum will allow the device to boot properly).

With an otherwise useless device and nothing to lose, I chose Option 2. Here are the steps I went through to put some more life into my Nexus 5.

Step 1: Remove the motherboard. There's a nice guide here: https://it.ifixit.com/Guide/Nexus+5+Motherboard+Replacement/64811

Step 2: Use a soldering iron to heat up and physically remove the defective power button from the motherboard.

Step 3: Reassemble the phone.

Step 4: Hold down the volume up and volume down buttons simultaneously while plugging the phone in. The phone should now boot into the bootloader screen.

Step 5: Plug the phone into a computer with adb/fastboot installed [see: https://developer.android.com/studio/releases/platform-tools.html], open Terminal, and type "fastboot reboot"; your phone should now boot your OS.

Step 5a: From here you can perform a factory reset if you simply want to remove all your data and sell your device (for parts) or recycle it.

Step 5b: If you want to make your device more or less usable, let's keep going!

Step 6: If you are lucky, your bootloader was already unlocked before your power button failed. If so, jump down to Step 15. Otherwise, if you are unlucky (like I was), you need to unlock the bootloader. But how to do this without a power button? Hmmm. The solution: a small piece of wire to "short" out the switch. [See: https://www.reddit.com/r/Nexus5/comments/3qp02o/possible_to_unlock_bootloader_without_power_button/]

Step 7: Enable ADB Debugging (under Developer Options) on your phone. If it's not already plugged in to your computer, plug it in.

Step 8: Open Terminal and type "adb reboot bootloader"

Step 9: In Terminal, type "fastboot flashing unlock" and use the Volume button to toggle to the "Yes" option.

Step 10: With everything powered, your phone connected to your computer, and "Yes" selected, remove the sim card tray, the back cover, and the midframe. Disconnect the front facing and rear facing cameras. Leave everything else connected.

Step 11: Carefully pry up the motherboard so you can access the power button solder pads and use the small bit of wire to "connect" the two pads. This should confirm the "Yes" option and unlock the bootloader.

Step 12: Carefully reassembled everything.

Step 13: With the phone still connected to your computer, type "fastboot reboot" in Terminal. Since you unlocked the bootloader your phone will be wiped during reboot and so the boot process will take a little longer than normal.

Step 14: Enable ADB Debugging. And then reboot into the bootloader.

Step 15: Install TWRP custom recovery. But without a power button, this is a little bit trickier than normal, since after flashing the recovery.img via fastboot you can't boot directly to recovery and thus your custom recovery will be overwritten by the stock recovery during the boot process. So...you need to use "fastboot boot recovery.img" to temporarily boot your custom recovery and from there you can properly install the custom recovery. Open a Terminal window in the folder containing your recovery image and type "fastboot boot yourrecovery.img" [in my case, I typed "fastboot boot twrp-3.2.1-1-hammerhead.img"].

Step 16: Once TWRP has loaded, you need to Install TWRP again within TWRP. Put your TWRP.img file into your phone's internal memory and then use the .img option in the Install menu to select and flash the TWRP.img you put into internal memory in to Recovery. TWRP should now officially be your phone's recovery.

Step 17: Reboot System via TWRP to ensure that all's well.

Step 18: If you didn't have a custom rom already installed before your power button failed, I recommend installing one, since there will likely be some additional functionality that will help mitigate the missing power button [like volume rocker wake]. I recommend OmniRom and that's what I installed.

Step 19: Flash SuperSU via TWRP.

Step 20: Reboot.

Step 21: Install a file explorer with root manager capability. I used ES File Explorer. You can find the .apk on apkmirror.com.

Step 22: Use your file explorer to edit /system/usr/keylayout/gpio-keys.kl and re-map power button to volume down by changing "key 114" from "VOLUME DOWN" to "POWER". Thanks [MENTION=2864540]Fihlvein[/MENTION] for this info!

Step 23: Reboot.

Step 24: Profit! Your Nexus 5 should be good to go!

NB: Unfortunately there's is still one annoyance to be dealt with: once you power off the phone there is still no way to turn the phone on without using the "fastboot reboot" method [Step 4] which means you need to have a computer nearby...which isn't always very handy. The solution is to keep your phone powered on and adequately charged.