  Motivated by recent reports of superconductivity in Sr-doped NdNiO$_2$ films
on SrTiO$_3$(001) [Nature (London) 572, 624 (2019)], we explore the role of the
polar interface on the structural and electronic properties of
NdNiO$_n$/SrTiO$_3$(001) ($n=2,3$) by performing first-principles calculations
including a Coulomb repulsion term. For infinite-layer nickelate films ($n=2$),
electronic reconstruction drives the surprising emergence of a two-dimensional
electron gas (2DEG) at the interface involving a strong occupation of the Ti
$3d$ states. This effect is more pronounced than in LaAlO$_3$/SrTiO$_3$(001)
and accompanied by a substantial reconstruction of the Fermi surface: a
depletion of the self-doping Nd $5d$ states and an enhanced Ni $e_g$ orbital
polarization reaching up to $35\%$ at the surface, reflecting a single hole in
the $3d_{x^2-y^2}$ states, i.e., cuprate-like behavior. In contrast, no 2DEG
forms for perovskite films ($n=3$) or if a single perovskite layer persists at
the interface. We show that the topotactic reaction from the perovskite to the
infinite-layer phase is confined to the nickelate film, whereas the SrTiO$_3$
substrate remains intact.
