  We show how a quasi-smooth derived enhancement of a Deligne-Mumford stack X
naturally endows X with a functorial perfect obstruction theory in the sense of
Behrend-Fantechi. This result is then applied to moduli of maps and perfect
complexes on a smooth complex projective variety. For moduli of maps, we
consider X=S an algebraic K3-surface, $g\geq 0$, and $\beta$ a curve class, and
we construct a derived stack whose truncation is the usual stack of pointed
stable maps from curves of genus g to S hitting the class $\beta$, and such
that the inclusion of the trunaction induces on a perfect obstruction theory
whose tangent and obstruction spaces coincide with the corresponding reduced
spaces of Okounkov-Maulik-Pandharipande-Thomas. We give two further
applications to moduli of complexes. For a K3-surface S we show that the stack
of simple perfect complexes on S is smooth. This result was proved with
different methods by Inaba for the corresponding coarse moduli space. Finally,
we construct a map from the derived stack of stable embeddings of curves (into
a smooth complex projective variety X) to the derived stack of simple perfect
complexes on X with vanishing negative Ext's, and show how this map induces a
morphism of the corresponding obstruction theories when X is a Calabi-Yau
threefold. An important ingredient of our construction is a perfect determinant
map from the derived stack of perfect complexes to the derived stack of line
bundles whose tangent morphism is, pointwise, Illusie's trace map for perfect
complexes. We expect that this determinant map might be useful in other
contexts as well.
