What are the groups $X$ for which there exists a group $G$ such that $G' \cong X$?

My considerations:

If $X$ is perfect we are happy with $G=X$.

If $X$ is abelian then $G := X \wr C_2$ verifies $G'=\{(x,x^{-1}): x \in X\} \cong X$.

If $X$ satisfies the following properties:

(1) $X \neq X'$, (2) The conjugation action $X \to \text{Aut}(X)$ is an isomorphism,

then there is no $G$ such that $G' = X$ (consider the composition $G \to \text{Aut}(X) \cong X \to X/X'$, it is surjective so its kernel contains $X$, contradiction). For instance, the symmetric group $S_n$ verifies (1) and (2) if $n \neq 2,6$.

I have been looking for this problem on the web but I didn't find anything.
Do you have any reference and/or suggestion on how to solve this problem?