Where do I place drywall screws when fixing nail pops?
Considering that this occurred on the ceiling beneath a roof space I wonder whether you're seeing the effects of a phenomenon called truss uplift. It's a very normal occurrence. In a nutshell, varying temperature and moisture content in the wood members of a roof truss can cause the lower chord to lift upward; it then floats above interior walls. When the truss moves up in this way one (or both) of two things happens: the drywall stays down with the wall and the nails back out from the truss, or the drywall moves with the truss, tears the joint tape, and a crack appears. If the nails back out from the wood when the truss lifts up then when the season changes the truss chord will relax downward and push the nail through the finish.

The solution is this: don't fasten drywall to the truss within 12-16 inches of an interior wall. One could drive the nails back in but they'll pop again. One could use screws that won't back out but it'll fail in some other, possibly worse way.

If you have access to the roof space above this place you could attach wood blocking to the top of the wall between the trusses. Remove those nails that popped (and don't replace them) and instead fasten the drywall to the new blocking.

If you don't have access to the roof space then just remove those nails and patch the texture.

Here are a few nice articles on truss uplift: Trim-Tex Drywall Products, Building Science, and Pro Builder.