Probing the metal-insulator transition of NdNiO3 by electrostatic doping