  We analyse the geometry of generic Minkowski $\mathcal{N}=1$, $D=4$ flux
compactifications in string theory, the default backgrounds for string model
building. In M-theory they are the natural string theoretic extensions of
$\mathrm{G}_2$ holonomy manifolds. In type II theories, they extend the notion
of Calabi--Yau geometry and include the class of flux backgrounds based on
generalised complex structures first considered by Gra\~na et al. (GMPT). Using
$\mathrm{E}_{7(7)}\times\mathbb{R}^+$ generalised geometry we show that these
compactifications are characterised by an
$\mathrm{SU}(7)\subset\mathrm{E}_{7(7)}$ structure defining an involutive
subbundle of the generalised tangent space, and with a vanishing moment map,
corresponding to the action of the diffeomorphism and gauge symmetries of the
theory. The K\"ahler potential on the space of structures defines a natural
extension of Hitchin's $\mathrm{G}_2$ functional. Using this framework we are
able to count, for the first time, the massless scalar moduli of GMPT solutions
in terms of generalised geometry cohomology groups. It also provides an
intriguing new perspective on the existence of $G_{2}$ manifolds, suggesting
possible connections to Geometrical Invariant Theory and stability.
