Crystal structure, stability, and electronic properties of hydrated metal sulfates MSO4(H2O)n (M=Ni, Mg; n=6, 7) and their mixed phases: A first principles study