Compactness of the moduli space of representations of fundamental group Let $M$ be a compact manifold and $G$ a compact Lie group. I am trying to deduce that the moduli space of flat connections on $M$ is compact, and for that I have shown that there is a correspondence between flat $G$-connections modulo gauge equivalence and equivalence classes of representations of the fundamental group of $M$, but now I can't see why this space of representations is compact.
I do not have much background in representation theory or algebraic topology, so I am mostly looking for a reference for this result. If this is something that should be clear from more basic results (if I had the background), a sketch of the proof would also be appreciated.
 A: (I'm assuming $M$ is connected; the disconnected case is not much more complicated since there are only finitely many connected components. Also, presumably $M$ is a smooth manifold here so you can talk about flat connections.)
The moduli space of flat connections is $\text{Hom}(\pi_1(M), G)/G$ (quotienting by the conjugation action of $G$). $\text{Hom}(\pi_1(M), G)$ is a closed subspace of $G^{\pi_1(M)}$ (cut out by the axioms of a homomorphism) which is compact Hausdorff by Tychonoff's theorem, so $\text{Hom}(\pi_1(M), G)$ is also compact Hausdorff. Hence its quotient by the conjugation action of $G$ is also compact (but not necessarily Hausdorff).
As far as I can tell, this argument does not require that $M$ is compact. If $M$ is compact we learn more, though: in that case $\pi_1(M)$ is finitely presented so $\text{Hom}(\pi_1(M), G)$ can be cut out of a finite product of copies of $G$ by a finite number of relations, and we learn that the moduli space of flat connections is "finite-dimensional" and even "algebraic" in a suitable sense.
This follows, for example, from the fact that compact manifolds have the homotopy type of finite CW complexes (which in particular have finitely many $0$-cells, $1$-cells, and $2$-cells); see, for example, this MO question. For compact smooth manifolds we can instead use Morse theory but I'm not sure what the precise statements are.
