Install The Android 4.4.2 KitKat Update On Your Rooted Nexus 5, Nexus 4 and Nexus 7 [How-To]
6. You can root your Nexus device automatically by rebooting into TWRP recovery once and then select the ‘Reboot’ command from there. TWRP recovery will then automatically give you an option to root your Nexus device. Swipe the arrow to the right to confirm, and wait for your device to reboot.
After it has rebooted, make sure to start SuperSu and update the binary for root access to work properly.
7. If the installation fails for some reason, you will have to flash an Android 4.4.2 based stock ROM on your device. The installation generally fails if it detects that any of the system APKs have been modified.
You can find the stock ROM for your Nexus device over at the XDA sub-forum for your device. You can install the stock ROM using the TWRP Manager app linked above.
If you are not able to find the link to the stock ROM on XDA forums, drop in a comment and I will be more than glad to link you to it.