  We present an analysis of the formation and chemical evolution of stellar
haloes around (a) Milky Way Analogue (MWA) galaxies and (b) galaxy clusters in
the L-Galaxies 2020 semi-analytic model of galaxy evolution. Observed stellar
halo properties are better reproduced when assuming a gradual stripping model
for the removal of cold gas and stars from satellites, compared to an
instantaneous stripping model. The slope of the stellar mass -- metallicity
relation for MWA stellar haloes is in good agreement with that observed in the
local Universe. This extends the good agreement between L-Galaxies 2020 and
metallicity observations from the gas and stars inside galaxies to those
outside. Halo stars contribute on average only $\sim{}0.1$ per cent of the
total circumgalactic medium (CGM) enrichment by $z=0$ in MWAs, ejecting
predominantly carbon produced by AGB stars. Around a quarter of MWAs have a
single `significant progenitor' with a mean mass of
$\sim{}2.3\times{}10^{9}M_{\odot}$, similar to that measured for Gaia
Enceladus. For galaxy clusters, L-Galaxies 2020 shows good correspondence with
observations of stellar halo mass fractions, but slightly over-predicts stellar
masses. Assuming a Navarro-Frenk-White profile for the stellar halo mass
distribution provides the best agreement. On average, the intracluster stellar
component (ICS) is responsible for 5.4 per cent of the total intracluster
medium (ICM) iron enrichment, exceeding the contribution from the brightest
cluster galaxy (BCG) by $z=0$. We find that considering gradual stripping of
satellites and realistic radial profiles is crucial for accurately modelling
stellar halo formation on all scales in semi-analytic models.
