No Junction Box for Ceiling Light
If the joist is directly over the hole, there is a junction box (called a saddle box) that actually fits around a joist. I found them when I was looking for boxes for ceiling fans. This might keep you from having to do a separate box in the attic. I found some at Lowe's, but seem to be widely available, and come in various configurations depending on how the hole aligns to the joist.