CVS Health Corp., the biggest U.S. retailer of prescription drugs, agreed to acquire nursing-home pharmacy Omnicare Inc. for a total enterprise value of $12.7 billion.