Since I do tons of trim carpentry, I keep on stock in my garage every conceivable nail known to man, in both iron and galvanized. And, I have a nice cut-off wheel that I used for cutting metal.
I have been reluctant to go this route because, almost all iron nails we now get are from China. Put a box of them in your garage for a year, and you may find rust growing all over them. Since they are very rust prone, I am reluctant to put them in the layout.
I could use galvanized nails of the same size, but I am not sure whether the galvanization would impede the flow of electricity between the rails. Every place the nails would touch the tracks, inside the pin holes, would have a galvanized coating, and if those impede electrical flow, the train wouldn't run.
I have also been buying some cheap used O gauge track, and in pulling those pins I have notice that several of them were nails, coated with rust, and the absolute devil to pull out. Often, you had to stretch the track rail open, and pull so hard, that it destroyed the rail ending.