If I understand correctly, Sean Carroll's Spacetime and Gravity says that the energy-momentum tensor for a perfect fluid
$$T^{\mu\nu} = (\rho + p)U^\mu U^\nu + pg^{\mu\nu}$$
can be obtained as the variation of the action for a scalar field with respect to the metric
\begin{align} T^{(\phi)}_{\mu\nu} &:= \frac {-2}{\sqrt{-g}}\frac{\delta S_\phi}{\delta g^{\mu\nu}}\\ &=\nabla_\mu \phi \nabla_\nu\phi - \frac 12 g_{\mu\nu}g^{\rho\sigma}\nabla_\rho \phi\nabla_\sigma \phi - g_{\mu\nu} V(\phi).\end{align}
Is this true? How so?
Also, is it possible to rewrite this as a "canonical energy-momentum tensor"?
$$S^{\mu\nu} = \frac{\delta \mathcal L}{\delta(\partial_\mu \Phi^i)}\partial^\nu\Phi^i - \eta^{\mu\nu}\mathcal L$$