You should try flashing the factory image for Nexus 5 in Fastboot.

 
 
 - Download Nexus 5X (bullhead) Factory image Android 7.1.1 [here][1] or Android 6.0.1 [here][2]. And unzip the file.
 
 
 
 - Setup all necessary drivers

 
 - For commands to succeed, you should unlock the bootloader: 
`fastboot oem unlock` or `fastboot flashing unlock`. The  device will show  a confirmation screen. (This erases all data on the device.)
 
 
 - Open a terminal and navigate to where you unzipped system image previously downloaded.
 
 - Execute the `flash-all script`. This script installs the necessary bootloader, baseband firmware, and  system.

Hope this helps you out. 
  [1]: https://dl.google.com/dl/android/aosp/bullhead-nmf26f-factory-7ad6b52c.zip
  [2]: https://dl.google.com/dl/android/aosp/bullhead-mmb29v-factory-09b6d3d2.zip