If you're doing a hobby project, they make mechanical shutoff valves that are water powered. Turn a dial for how much water you want and it shuts off after so many gallons. You could theoretically attach a motor/servo to crank the dial and then not need any power to let it run and shutoff.
But I'd just get a standard sprinkler system and wire it to the mains like normal. Hobby projects often cost more than they save, and anyone buying the home would insist on having it replaced with something standard as part of the sale.