Interplay between breathing-mode distortions and magnetic order in rare-earth nickelates from ab initio magnetic models