Remove furniture from the room or cover them with drop cloth. The repair will bring down some drywall material and dust.
Switch off the power source of the light fixture, preferably at the circuit breaker; then carefully uninstall the light fixture.
Pull out the old nails from the joists. Use a pair of pliers or small crowbar. You won't be able to reach all of them, but try to remove those that you can.
Push up the fallen drywall panel back in place using a wallboard jack or a couple of wood planks. A wallboard jack, which is sometimes available for rent at a home improvement center, is similar to a car jack and would be ideal for ceilings higher than 8 feet. For standard ceilings, 8-foot wood planks, which are relatively cheap (and reusable), would do the job just as well.
Thin scraps of wood or shims will help raise the wood planks a few inches if required. Be sure to secure the foothold of the wallboard jack or wood plank to prevent accidents; use a rubber mat if the support tends to slide across a smooth floor. A floor mat will also help protect the floor.
Reattach the panels to the joists with screws, making sure to drive the screws just flush to the surface for a smooth finish. Position the new screws about 1 to 2 inches away from the holes where the old nails popped off. Add a few more screws for added security.
Decide whether you want to re-tape, re-spackle and re-paint over the repair, or change the finish of the whole ceiling.
Decide whether you want to use the old light fixture or install a new one. Install light fixtures on the joists this time.