Homotopy nilpotency and localization