I'm glad to see someone else thought to mention the Create mod when faced with this question, however, one must also mention the addon mod Create: Interactive, it would in theory allow you to create a self-perpetuating giant train base that drills its path forward, creates more rail in a built in production line with the drilled stone and deploys it automatically. Let's not forget the one addon specifically made to expand the train system as well.