To define a $G$-connection on a $G$-principal bundle I was looking for a definition of $G$ connection over a $G$-principal bundle over a topological space $X$. $G$ is a topological group. But I find only the case when $X$ is a manifold. Instead, I would have it in the case of an algebraic curve, or in the more general case of a topological space only.
 A: In the context of algebraic varieties (more generally, schemes) it is easier to define connections on vector bundles; for principal bundles, you will use the associated vector bundle via the adjoint representation. (Going from connections on vector bundles to connections on principal bundles is the same as in the setting of differentiable manifolds.)
Let $X$ be an algebraic variety with the cotangent sheaf $T^*X$, $E\to X$ a vector bundle (more generally, a locally-free sheaf). Then an (algebraic) connection on $E\to X$ is a family of derivations
$$
\Gamma(E, U)\to \Gamma(T^*U \otimes E)
$$
where $U$'s are open subsets of $X$,
commuting with the restriction maps of the sheaf of sections of $E$.
One can in principle make this work when $X$ is merely a topological space but then you have to be given an auxiliary sheaf $A^\bullet(X)$ on $X$ replacing the sheaf of forms $\Omega^\bullet(X)$: $A^\bullet(X)$ is a sheaf of differential graded associative algebras. Then a connection will be a family of derivations
$$
\Gamma(E, U) \to \Gamma(A^1(U) \otimes E|_U).
$$
You can then define (formally) the curvature using the differential $A^1(X)\to A^2(X)$.
For a general topological space and a principal $G$-bundle $P\to X$, a flat connection is the same as a 1-cocycle on $X$ with values in $G^\delta$ (the group $G$ equipped with discrete topology). Concretely, this means that you get a covering ${\mathcal U}$ of $X$ and for any two $U_i, U_j\in {\mathcal U}$ you associate $g_{ij}\in G$ such that whenever
$$
U_i\cap U_j\cap U_k\ne \emptyset,
$$
$$
g_{ij} g_{jk} g_{ki}=1.
$$
This is discussed in great detail in
Steenrod, Norman, The topology of fibre bundles., Princeton Landmarks in Mathematics. Princeton, NJ: Princeton University Press. viii, 229 p. (1999). ZBL0942.55002.
Such an object is also called a flat bundle.
If $X$ is path-connected and $x\in X$ is a base-point then defining a flat $G$-bundle  over $X$ is equivalent to taking a $G$-conjugacy class of a homomorphism $\pi_1(X,x)\to G$ (the holonomy/monodromy group of the flat bundle).
The point is when you have a smooth bundle $P$ over a smooth manifold $X$ then flatness of a connection on $P$ is equivalent to the above structure.
