  We analyse the rigidity of discrete energies where at least nearest and
next-to-nearest neighbour interactions are taken into account. Our purpose is
to show that interactions beyond nearest neighbours have the role of penalising
changes of orientation and, to some extent, they may replace the
positive-determinant constraint that is usually required when only nearest
neighbours are accounted for.} In a discrete to continuum setting, we prove a
compactness result for a surface-scaled energy and we give bounds on its
possible Gamma-limit.
  In the second part of the paper we follow the approach developed in the first
part to study a discrete model for (possibly heterogeneous) nanowires. In the
heterogeneous case, by applying the compactness result shown in the first part
of the paper, we obtain an estimate on the minimal energy spent to match
different equilibria. This gives insight into the nucleation of dislocations in
epitaxially grown heterostructured nanowires.
