[Nexus 5 General] BioT3rm:
Hello all today I will be showing you how to flash Kali Nethunter 2.0 onto your Nexus 5 device running AOSP 5.1.1_r13.

Prerequisites:

Custom recovery, I recommend TWRP 2.8.7.1 (I used it for this tutorial)

Updated bootloader which can be found here: Bootloader & Radio update

Supersu v2.46 Download

First let's setup our build environment.

Java Development Kit 7:

sudo apt-get install openjdk-7-jdk

The build tools:

sudo apt-get install git gnupg flex bison gperf build-essential
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386
libgl1-mesa-dev g++-multilib mingw32 tofrodos
python-markdown libxml2-utils xsltproc zlib1g-dev:i386

The repo command:

mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo

Let's add bin to our path, the first step here is for Ubuntu 14.04 (Not sure if later distro's are the same) and the second step is for Linux Mint 17+

Step 1 (Ubuntu):

sudo gedit .bashrc
export PATH=~/bin:$PATH <-(add to end of bashrc)

Step 2 (Mint):

sudo gedit /etc/bash.bashrc
export PATH=~/bin:$PATH <-(add to end of bashrc)

Identify yourself to the repo:

git config --global user.email "you@youremail.com"
git config --global user.name "yourpreferredusername"

Sync the Repo (This may take awhile):

mkdir ~/Source
cd ~/Source
repo init -u https://android.googlesource.com/platform/manifest -b android-5.1.1_r13
repo sync

After the repo has synced fully you must install the Nexus 5 binaries which are below into the root of the Source (or whatever you called it) folder.

Binaries:

NFC, Bluetooth & Wifi (Broadcom) for 5.1.1 - Download

Camera, Sensors & Audio (LG) for 5.1.1 - Download

Graphics, GSM, Camera, GPS, Sensors, Media, DSP & USB (Qualcom) for 5.1.1 - Download

Jump into ~/Source (Your folder) and run envsetup:

cd ~/Source && source build/envsetup.sh

Choose the device (It should be number 8)

lunch

Let's build our rom:

make -j4 otapackage

the -j flag can be specified depending on your CPU on mine I get a good rate at -j8 (HexaCore 3.5GHz)

GAPPS:

I used the PICO modular package due to wanting the smallest Google fingerprint from here http://xdaforums.com/android/software/tk-gapps-t3116347

After copying everything to your sdcard you can now perform a full wipe (After a backup of course) and flash the newly built rom from ~/Source/out/target/product/hammerhead/ and then flash gapps (Not required) & SuperSU and then reboot into your pure AOSP rom.

Flash SuperSU before rebooting your phone as it's required for the next step

After a full reboot of the system update busybox to the latest release and the download Kali Nethunter from here and flash in recovery

I Take no responsibility if your device becomes bricked I made this tutorial for educational purposes as I had no problem flashing my device with the above steps.

EDIT Optional Step:

I Also flashed the ElementalX Kernel BEFORE flashing Kali Nethunter, this is not a requirement but this may help with battery drain ElementalX.org

CREDITS:

@osm0sis For the GAPPS (Awesome guy)

Offensive Security For Kali Nethunter (Thanks guys)

@scrosler For his tutorial on how to build AOSP from source (Taught me alot)

@Chainfire For the most excellent SuperSU

TeamWin For their awesome recovery

@flar2 for a wicked kernel

If i've forgotten anyone then let me know I'll add you