A state of emergency has been declared in San Francisco as a wildfire 150 miles away threatens both power and water supplies to the city.