Trying to find the solution by variation of parameters one proceeds with the parametrization of the general solution as
$$
y(x)=c_1(x)\cos(x)+c_2(x)\sin(x).
$$
In the first derivative one fixes the relation between $c_1$ and $c_2$ by demanding
$$
c_1'(x)\cos(x)+c_2'(x)\sin(x)=0
$$
The remaining terms of the first derivative are
$$
y'(x)=-c_1(x)\sin(x)+c_2(x)\cos(x).
$$
Then insert the second derivative into the ODE which gives
$$
-c_1'(x)\sin(x)+c_2'(x)\cos(x)=(x-1)\cos(x).
$$
Now isolating the derivatives can be done via the trigonometric identity $\cos^2(x)+\sin^2(x)=1$ to find
\begin{align}
c_1'(x)&=-(x-1)\cos(x)\sin(x),\\
c_2'(x)&=(x-1)\cos^2(x).
\end{align}
This can now be integrated via the double-angle identities and partial integration.
Another way to look at this is to write the linear system in matrix form
$$
\pmatrix{\cos x&\sin x\\-\sin x&\cos x}
\pmatrix{c_1'(x)\\c_2'(x)}
=
\pmatrix{0\\(x-1)\cos x}
$$
where the system matrix can be identified with the Wronski-matrix of the fundamental system $(\cos x, \sin x)$. The Wronskian determinant is $1$, so that solving the system proceeds by multiplying with the transpose matrix, giving the same derivatives.