We construct a Chern-Simons gauge theory for dg Lie and L-infinity algebras on any one-dimensional manifold and quantize this theory using the Batalin-Vilkovisky formalism and Costello's renormalization techniques. Koszul duality and derived geometry allow us to encode topological quantum mechanics, a nonlinear sigma model of maps from a 1-manifold into a cotangent bundle as such a Chern-Simons theory. Our main result is that the partition function of this theory is naturally identified with the A-hat genus of the target manifold. From the perspective of derived geometry, our quantization constructs a volume form on the derived loop space which can be identified with the A-hat class.