Once and for all, I need a cheat sheet for tensor calculus, to avoid having to recalculate things from scratch every time I deal with a new (or for that matter, old) theory.

 First, differentiation of the metric tensor with respect to the metric. Obviously,

\begin{align}
{\dfrac{\partial g_{\alpha\beta}}{\partial g_{\mu\nu}}=\delta^\mu_\alpha\delta^\nu_\beta.}
\end{align}

Now, given that $g^{\alpha\beta}g_{\beta\gamma}=\delta^\alpha_\gamma$ and the derivative of the Kronecker-delta is identically zero, we can compute the derivatives of the contravariant metric tensor:

\begin{align}
\frac{\partial}{\partial g_{\mu\nu}}g^{\alpha\beta}g_{\beta\gamma}=0&=\frac{\partial g^{\alpha\beta}}{\partial g_{\mu\nu}}g_{\beta\gamma}+g^{\alpha\beta}\delta^\mu_\beta\delta^\nu_\gamma,\\
\frac{\partial g^{\alpha\beta}}{\partial g_{\mu\nu}}g_{\beta\gamma}&=-g^{\alpha\mu}\delta^\nu_\gamma,\\
\frac{\partial g^{\alpha\beta}}{\partial g_{\mu\nu}}g_{\beta\gamma}g^{\gamma\kappa}&=-g^{\alpha\mu}\delta^\nu_\gamma g^{\gamma\kappa},\\
\frac{\partial g^{\alpha\kappa}}{\partial g_{\mu\nu}}&=-g^{\alpha\mu}g^{\kappa\nu}.
\end{align}

Therefore,

\begin{align}
{\dfrac{\partial g^{\alpha\beta}}{\partial g_{\mu\nu}}=-g^{\alpha\mu}g^{\beta\nu}.}
\end{align}

Next, derivatives of the Christoffel-symbols with respect to the metric. Given

\begin{align}
{\Gamma^\gamma_{\alpha\beta}=\frac{1}{2}g^{\gamma\delta}\left(\partial_\alpha g_{\beta\delta}+\partial_\beta g_{\alpha\delta}-\partial_\delta g_{\alpha\beta}\right),}
\end{align}

we obtain

\begin{align}
{\dfrac{\partial\Gamma^\gamma_{\alpha\beta}}{\partial g_{\mu\nu}}=g^{\mu\gamma}\Gamma^\nu_{\alpha\beta}.}
\end{align}

When dealing with Lagrangians, we also need to differentiate with respect to $\partial_\kappa g_{\mu\nu}$:

\begin{align}
\frac{\partial\Gamma^\gamma_{\alpha\beta}}{\partial(\partial_\kappa g_{\mu\nu})}=\frac{1}{2}g^{\gamma\delta}\left(\delta^\kappa_\alpha\delta^\mu_\beta\delta^\nu_\delta+\delta^\kappa_\beta\delta^\mu_\alpha\delta^\nu_\delta-\delta^\kappa_\delta\delta^\mu_\alpha\delta^\nu_\beta\right),
\end{align}

or

\begin{align}
{\dfrac{\partial\Gamma^\gamma_{\alpha\beta}}{\partial(\partial_\kappa g_{\mu\nu})}=\dfrac{1}{2}\left(\delta^\kappa_\alpha\delta^\mu_\beta g^{\gamma\nu}+\delta^\kappa_\beta\delta^\mu_\alpha g^{\gamma\nu}-\delta^\mu_\alpha\delta^\nu_\beta g^{\gamma\kappa}\right).}
\end{align}

The coordinate derivative of the contravariant metric tensor can be expressed in terms of the covariant metric tensor's derivative in a similar way:

\begin{align}
{\partial_\mu g^{\alpha\beta}=-g^{\alpha\gamma}g^{\beta\delta}\partial_\mu g_{\gamma\delta}.}
\end{align}

Finally, let us consider coordinate derivatives of the Christoffel symbols:

\begin{align}
{\partial_\kappa\Gamma^\gamma_{\alpha\beta}=-\frac{1}{2}g^{\gamma\epsilon}\partial_\kappa g_{\epsilon\zeta}\Gamma^\zeta_{\alpha\beta}+\frac{1}{2}g^{\gamma\delta}\left(\partial_\alpha\partial_\kappa g_{\beta\delta}+\partial_\beta\partial_\kappa g_{\alpha\delta}-\partial_\delta\partial_\kappa g_{\alpha\beta}\right),}
\end{align}

\begin{align}
{\dfrac{\partial}{\partial g_{\mu\nu}}\partial_\kappa\Gamma^\gamma_{\alpha\beta}=\frac{1}{2}g^{\gamma\mu}g^{\epsilon\nu}\partial_\kappa g_{\epsilon\zeta}\Gamma^\zeta_{\alpha\beta}-\frac{1}{2}g^{\gamma\epsilon}\partial_\kappa g_{\epsilon\zeta}g^{\mu\zeta}\Gamma^\nu_{\alpha\beta}-\frac{1}{2}g^{\mu\gamma}g^{\nu\delta}\left(\partial_\alpha\partial_\kappa g_{\beta\delta}+\partial_\beta\partial_\kappa g_{\alpha\delta}-\partial_\delta\partial_\kappa g_{\alpha\beta}\right),}
\end{align}

\begin{align}
{\dfrac{\partial}{\partial(\partial_\rho g_{\mu\nu})}\partial_\kappa\Gamma^\gamma_{\alpha\beta}=-\frac{1}{2}g^{\gamma\mu}\delta^\rho_\kappa\Gamma^\nu_{\alpha\beta}-\frac{1}{4}g^{\gamma\epsilon}\partial_\kappa g_{\epsilon\zeta}\left(\delta^\rho_\alpha\delta^\mu_\beta g^{\zeta\nu} + \delta^\rho_\beta\delta^\mu_\alpha g^{\zeta\nu}-\delta^\mu_\alpha\delta^\nu_\beta g^{\zeta\rho}\right),}
\end{align}

\begin{align}
{\dfrac{\partial}{\partial(\partial_\rho\partial_\sigma g_{\mu\nu})}\partial_\kappa\Gamma^\gamma_{\alpha\beta}=\frac{1}{2}\delta^\sigma_\kappa\left(\delta^\rho_\alpha\delta^\mu_\beta g^{\gamma\nu}+\delta^\rho_\beta\delta^\mu_\alpha g^{\gamma\nu}-\delta^\mu_\alpha\delta^\nu_\beta\ g^{\gamma\rho}\right).}
\end{align}

Last but not least, the derivative of the covariant volume element:

\begin{align}
{\dfrac{\partial}{\partial g_{\mu\nu}}\sqrt{-g}=\frac{1}{2}g^{\mu\nu}\sqrt{-g}.}
\end{align}

This is all we need to compute derivatives of the Ricci-tensor that are relevant for variational calculus. We define the Riemann curvature tensor as

\begin{align}
{R_\mu{}^\alpha{}_{\nu\beta}=\partial_\beta\Gamma^\alpha_{\mu\nu}-\partial_\nu\Gamma^\alpha_{\mu\beta}+\Gamma^\kappa_{\mu\nu}\Gamma^\alpha_{\kappa\beta}-\Gamma^\kappa_{\mu\beta}\Gamma^\alpha_{\kappa\nu},}
\end{align}

while the Ricci tensor is given by

\begin{align}
{R_{\mu\nu}=R_\mu{}^\alpha{}_{\nu\alpha}=\partial_\alpha\Gamma^\alpha_{\mu\nu}-\partial_\nu\Gamma^\alpha_{\mu\alpha}+\Gamma^\kappa_{\mu\nu}\Gamma^\alpha_{\kappa\alpha}-\Gamma^\kappa_{\mu\alpha}\Gamma^\alpha_{\kappa\nu},}
\end{align}

and the Ricci scalar is given by $R=g^{\mu\nu}R_{\mu\nu}$.

As it turns out, for a general Lagrangian density that depends on the metric and its first and second derivatives (and other fields), the Euler-Lagrange equation with respect to the metric is given by

\begin{align}
{-\frac{1}{2}g^{\mu\nu}{\cal L}-\frac{2}{3}\dfrac{\partial{\cal L}}{\partial(\partial_\gamma\partial_\mu g_{\alpha\beta})}R_\beta{}^\nu{}_{\alpha\gamma}-\nabla_\lambda\nabla_\kappa\dfrac{\partial {\cal L}}{\partial(\partial_\lambda\partial_\kappa g_{\mu\nu})}=0.}
\end{align}

This indicates that the only derivative of the Lagrangian we need is with respect to second derivatives of the metric tensor. Specifically, for the Ricci-scalar multiplied by the volume element, this derivative is given by

\begin{align}
{\dfrac{\partial R\sqrt{-g}}{\partial(\partial_\lambda\partial_\kappa g_{\mu\nu})}=-\dfrac{\sqrt{-g}}{2}(2g^{\mu\nu}g^{\kappa\lambda}-g^{\mu\kappa}g^{\nu\lambda}-g^{\mu\lambda}g^{\nu\kappa}).}
\end{align}

Lovelock, David and Rund, Hanno: Tensors, Differential Forms, and Variational Principles, Dover Publications, 1989.