Role of magnetic and orbital ordering at the metal-insulator transition in NdNiO 3