Theo Attissogbe scored a last-gasp try as France withstood a remarkable second-half rally from South Africa to win the inaugural Nations Championship final 40-34.