Simulating cosmic metal enrichment by the first galaxies