Quantum simulation methods based on density-functional theory are currently deemed unfit to cope with atomic heat transport within the Green-Kubo formalism, because quantum-mechanical energy densities and currents are inherently ill-defined at the atomic scale. We show that, while this difficulty would also affect classical simulations, thermal conductivity is indeed insensitive to such ill-definedness by virtue of a sort of gauge invariance resulting from energy extensivity and conservation. Based on these findings, we derive an expression for the adiabatic energy flux from density-functional theory, which allows heat transport to be simulated using ab-initio equilibrium molecular dynamics. Our methodology is demonstrated by comparing its predictions with those of classical equilibrium and ab-initio non-equilibrium (Muller-Plathe) simulations for a liquid-Argon model, and finally applied to heavy water at ambient conditions.