Modesto Irrigation District, which provides energy and water to farms and cities in California’s San Joaquin Valley, approved a $131-million contract this week to buy more than 2.5 million megawatt-hours of electricity over 20 years from a solar farm in eastern Riverside County, near the Arizona border. That’s enough electricity to supply roughly 18,000 average homes, or nearly one-fifth of Modesto’s residential customers.