Chemoautotrophs are organisms that obtain their energy via oxidizing inorganic compounds and then using that energy to synthesize ATP. The ATP can then be used to create more complex organic compounds.
Nitrifying bacteria are capable of chemoautotrophy. They oxidize ammonia or nitrite into nitrate, thus creating ATP. They then fix carbon into sugar using the Calvin cycle as done in plants.