My layout is 100% extruded foam boards.
My track (Atlas N scale Code 80) is held down with simple straight pins... that's it. It's been holding well for over 2 years now.
Midwest Products cork roadbed is glued to the foam using Elmers Glue-All. The Atlas Code 80 track is held to teh cork with straight pins in about every other pre-drilled nail hole, so about 1 every 5 inches plus a straight pin in the hole closest to a joint.
So I get the comments about homasote holding nails better, especially for hand laying your own track, but for store bought pieces (even flex) in my experience, extruded foam holds things just fine.
Edit to add, that half my layout is ballasted, so I can't really count that side, but teh other half is not ballasted, so even without ballast holding things in place, the straight pins have held just fine.