Apply a complete firmware image
First you must have the Android SDK installed, in this exemple in /data/Applications/AndroidSDK/.
Download the appropriate system image at:
https://developers.google.com/android/nexus/images
Then unzip it.
Connect your device to your computer over USB and enable USB debugging in developper settings.
Type in terminal:
sudo /data/Applications/AndroidSDK/platform-tools/adb reboot bootloader
To reboot your phone in bootloader mode.
Then unlock the bootloader with:
sudo /data/Applications/AndroidSDK/platform-tools/fastboot flashing unlock
Click on YES with power button
Flash the image previously downloaded with:
sudo ./flash-all.sh
Once the phone has started, shut it down, then reboot in bootloader mode by pressing POWER + VOL UP + VOL DOWN while the phone boots.
In order to lock the bootloader, then type:
sudo /data/Applications/AndroidSDK/platform-tools/fastboot flashing lock
Click on YES with power button