We already know that Nexus devices are easy to unlock and root, but the process is still a bit different each time. Thus, XDA member HQRaja posted a handy guide on exactly how to root the Nexus 4.

There are two different ways of rooting the device - using either ADB with an insecure boot image, or directly through ClockworkMod Recovery. While both methods are posted in the source thread at XDA, the CWM method is undoubtedly easier and will probably feel more familiar to most. Ergo, we're going to focus on doing it that way.

First off, this requires working fastboot and adb. If you don't have that set up, a quick Google search should provide a decent how-to. Past that, you'll need CWM, the appropriate drivers, and the flashable SuperSU package, all of which can be found at XDA. After downloading all of the required files, go ahead and plug the phone into your computer, transfer the SuperSU file onto the storage partition, make sure you have "USB debugging" enabled in Developer Options (if you don't see dev options, go into About phone and tap the build number seven times) and reboot into the bootloader.

Update:  Koush just released the official ClockworkMod Recovery for the N4, which you should probably use instead of the port. You can find that download here. (Make sure to modify the commands down below appropriately if you choose to use the official CWM Recovery.

adb reboot bootloader

Once in the bootloader, you'll need to go ahead and unlock the phone.

Unlocking the bootloader will factory reset the device.

fastboot oem unlock

The device should then reboot - if it goes into the normal setup, go ahead a reboot back into the bootloader using adb reboot bootloader. From there, you're going to launch CWM - note that this doesn't install CWM, it merely boots it so you can flash SU and busybox.

You must launch the command from the directory where the recovery file is.

fastboot boot cwm-recovery-mako.img

After that, use the volume rocker to navigate to the "recovery" option, and hit the power button. In recovery, you can make a backup if you choose, then flash the SuperSU/busybox file that you downloaded earlier.

Boom. You're done. Reboot and enjoy.

If you hit any snags or would prefer to use the other method, check out this thread on XDA.

[via Addictive Tips]