Nostoc can be found in soil, on moist rocks, at the bottom of lakes and springs (both fresh- and saltwater), and rarely in marine habitats. It may also grow symbiotically within the tissues of plants, such as the evolutionarily ancient angiosperm Gunnera and the hornworts (a group of bryophytes), providing nitrogen to its host through the action of terminally differentiated cells known as heterocysts. These bacteria contain photosynthetic pigments in their cytoplasm to perform photosynthesis.