Check out this video of sideofburritos:
https://yewtu.be/watch?v=NJzA9yRGgeM
He is a youtuber who makes good tips about grapheneos, but he is quite intermittent.
In this video he shows how to set up contact synchronization from 0 using nextcloud.
I will also leave you a tip that does not speak on video. If you already have the users saved in your contacts export them, and save the file. Once you are done following the tutorial import them all again because they will sync with nextcloud directly. The contacts app, once the contact exists, does not allow you to change the way it is backed up.