Android 6.0 Marshmallow for Nexus 4
Experience Android Marshmallow on your Nexus 4 using this pure AOSP buildXDA

After the pre-built AOSP Android Marshmallow ROM for Nexus 4 which can be used to install the latest Android version unofficially, another developer, vocodersm, from the XDA forum has released a custom firmware. He describes it as pure AOSP experience for the fourth generation Nexus phone.

As the ROM is still under development and might not be fully functional, caution is advised. The developer notes that the stock browser generates soft reboot when you share location and don't give accuracy for the location services.

The Nexus can be rooted after the update using the SuperSU beta version 2.51, thanks to Chainfire. Along with the root package, you need a modified boot image for rooting.
Users can head over to the guide below to install and root Android 6.0 on nexus 4. Rooting, installing ROM and recovery void the warranty of the phone. Create a backup of your phone's data. The following tutorial uses TWRP recovery, the download link for which can be found below.

Download files

AOSP ROM
Gapps

How to install Android 6.0 Marshmallow AOSP ROM on Nexus 4

Step-1: Connect your Nexus 4 to the PC using USB cable. Transfer the downloaded files to the internal storage of the phone and remember the location

Step-2: Unplug the USB cable from the phone and switch it off

Step-3: Boot your phone into recovery mode. Use Quick Boot app, available in the Play Store, to enter recovery mode. Alternatively, use the following steps to manually place the device into recovery

  • Press and hold the Volume Up, Volume Down and Power buttons together until your phone turns on. Now you should see Start with an arrow around it on the screen
  • Press the Volume Down button twice to highlight Recovery
  • Press the Power button to restart into Recovery mode

Step-4: In recovery, first create a backup of the current phone setup, which you would be able to restore anytime if something goes wrong with the new ROM. From recovery tap on backup and then do a swipe on the bottom of the screen to confirm the process

Step-5: Performing factory reset is must with this installation. For this, select Wipe, Advanced wipe and select Dalvik Cache, System, Data and Cache and then do a swipe on Swipe to wipe option

Step-6: Return to recovery, select Install then Storage. Now browse to the location where you have saved the AOSP ROM, select it and do a swipe on the Swipe to confirm flash option

Step-7: When the flashing finishes, repeat the similar process to install Gapps

Ste-8: After the installation is completed, select Reboot system to boot the phone

How to root Nexus 4 on Android 6.0 Marshmallow

Download files

Boot image (Mirror)
TWRP recovery
SuperSU 2.51

Step-1: Keep the above downloaded files in a separate folder and name it to anything you want, may be rootnexus4

Step-2: Inside the folder, rename the TWRP recovery file to twrp.img and boot image to boot.img for easy execution of the commands that you will use later in the guide

Step-3: Ensure that you have installed ADB and Fastboot drivers on your PC

Step-4: Connect the phone to the PC and move the SuperSU root file to the storage of your phone

Step-5: Disconnect the phone and boot into bootloader mode (Check the steps noted above for this)

Step-6: Open a command window inside the rootnexus4 folder in which you have saved the boot and TWRP files

Open the rootnexus4 folder, hold Shift key + right click on an empty space inside the folder. You should see a drop down menu, select Open command window here option

Step-7: Enter the following command to check whether fastboot is working or not

  • fastboot devices

You should see a serial number with fastboot written after it. If it does not appear, it means you need to reinstall adb and fastboot drivers, restart the PC or use an original USB cable

Step-8: Unlock the bootloader of the phone if it is locked. But this process will erase all data. Type in the following command

  • fastboot oem unlock

Step-9: Now press the Volume Up button on the phone to select Yes. Since this process will wipe out everything, you need to copy SuperSU root package to your phone's storage again

Step-10: Execute the following command to flash the boot image

  • fastboot flash boot boot . img

Step-11: Flash TWRP recovery using the command below

  • fastboot flash recovery twrp . img

Step-12: Once the installation is completed, disconnect the phone from the PC and reboot the phone into recovery mode

Use the Volume Up/Down button to get the Recovery menu and then use the Power button to select it. Your phone will be in TWRP recovery now

Step-13: From recovery, select install locate the SuperSU root file, select it and do a swipe to confirm flash option at the bottom of the screen

In the end just select Reboot system to restart your phone, which should be rooted now. More details about the pure AOSP ROM are available on the XDA thread here.