I've done this recently for a client. I used 3mm x 2mm neodymium magnets which were fine for the
HYMP arms but not quite strong enough to support the rail rifle - this was easily solved by adding a small pin. I also put two pins where the arm joins the rail rifle which made the whole thing much more secure.
You can see where the pins and magnets are here:
I'm sure there are different ways of doing it that would work just as well, but hopefully this will be of some help to you.