This is Nexus5, not 5x which is a little different.
In your Nexus5, go to Settings and tap ____ seven times to unlock developer. Also turn on ______. Now you need more than just your phone.
First Download UBPorts (Linux or I think Windows)
(Keep reading this paragraph) Second, download Android SDK Tools to use to unlock the OEM bootloader on the phone. THis is at developer.android.com/studio, and you scroll down to Command Line Tools Only: stkmanager. There's a Linux option as well there. THAT didn't work, since they don't seem to make available the SDK Tools, just the full version and a few other things. Intsead, go to forum.xda-developers.com for toolkit-wugs-nexus-root-toolkit where he has a link to the Nexus Root Toolkit, and download that.
Open that program and plug the Nexus 5 into the computer with USB. When you plug it in you'll see a message on the phone saying 'allow?' and you want to check 'always allow' and then click OK. Now with the program, you can 'Unlock' the bootloader. Then the phone will reboot itself as part of this same process executed by the Wugs program.
I didn't bother to 'root' the phone, but went and did UBPorts next. It didn't detect it was a Nexus 5 so I picked it manually.
A YouTube video you can follow: https://www.youtube.com/watch?v=KnlUdjUaD3Q&t=85s