The evolution of nitrogen fixation in cyanobacteria