Islamist militants have killed up to 30 soldiers in an attack on a military base in northeast Nigeria, security sources said on Saturday, in one of the biggest attacks of its kind this year.