Little article to explain how to root the Nexus 4 (of course using a GNU/Linux distro!).
Unlock the bootloader
Since this is a Google Phone, it’s very easy and do not require special tools, but only the Android SDK with adb (on Archlinux you can install it via AUR package android-sdk-platform-tools) and of course you need to plug an USB cable! Just type:
adb reboot bootloader
When your are in the bootloader, use the command “fastboot” given by Android SDK to unlock it. Warning! It will wipe all your data!
fastboot oem unlock
Install custom recovery image
Reboot again to the bootloader and flash a custom recovery image. I recommend to use Clockwork Recovery.
fastboot flash recovery '/path/to/the/recovery/image/recovery-clockwork-220.127.116.11-mako.img'
Now, the Clockwork Recovery should be installed in place of initial recovery. Reboot in normal mode, download SuperSu and put the zip file in the root of sdcard.
Reboot in recovery mode (using adb or vol down + power.) and install SuperSu using “install zip from sdcard”. And your done, your Nexus 4 is now rooted!
Bonus: You can now replace SuperSu by Superuser (found on F-Droid), an Opensource clone to the binary “su” and the Android Application which permit to authorize applications to be root.