A Nashville, Tenn., police officer was shot Tuesday evening in an ambush-style attack while responding to a home where a gunman had lured officers before opening fire and eventually killing himself, police said.