Q: How do I get my chickens to sleep on their roosts instead of in their nest boxes at night?
A: Having your chickens sleeping in their nests at night sounds like a natural thing, doesn't it? However, unless your hens are broody and hatching fertile eggs, having them sleep in the nests is a bad idea. As they sleep, they will defecate and soil the nests, and this means that when you do gather eggs, your eggs are likely to be dirty--yuck!
Your flock should be sleeping on their roosts.
Chickens should sleep on their roosts, NOT in nests
For that reason, it can be helpful not to add nest boxes to your coop until a few weeks before your chickens begin to lay so they don't develop any bad habits. If that is not possible (coops are often constructed with the nest boxes built in), then you can try covering or blocking off access to the nests. Something else to try is to make sure that your roosts are higher up than your nests. If your nests are the highest spot in your coop, your birds will be sorely tempted to roost there no matter what. It is instinct that they will naturally seek out the highest place available to retire at night.
Finally, make sure you're providing comfortable roosts. Chickens actually prefer flat, wide roosts as opposed to something round, like a pole or pipe. In fact, while using a metal pipe as a roost sort of seems like a good idea---it's nice and strong and smooth!---it could lead to frostbitten toes in cold areas. The pipe will get bitter cold, and the round roosts mean your chickens' toes will be sticking out from under their feathers at night. So instead, use something like a 2 x 4, wide side up. The wood won't conduct as much heat away from your flock's feet, plus their toes will have a little extra insulation under their feathers on cold nights.