  Let X be a proper scheme and Z a prestack over X equipped with a flat
connection. We give a local-to-global description of D-modules on the prestack
S(Z) of flat sections of Z. Examples of S(Z) include the moduli stacks of
principal G-bundles and de Rham local systems on X. We show that the category
of D-modules is equivalent to the category of ind-coherent sheaves which are
equivariant with respect to infinitesimal Hecke groupoids parametrized by
finite subsets of X. We describe a number of applications to geometric
representation theory and conformal field theory, including a derived
enhancement of the Verlinde formula: the derived space of conformal blocks
(a.k.a. chiral homology) of the WZW model is isomorphic to the cohomology of
the corresponding line bundle on Bun_G, the moduli stack of G-bundles.
