Ceiling light fixtures should be sealed off from your attic. Ideally, there would be no way for a fly in your attic to enter your living space. In practice, there are usually openings. Common ones to look out for:
- Around electrical boxes. The box your light fixture attaches to should be seated within your ceiling, but often the hole in your ceiling is bigger, leaving a gap around the box. You can seal this with spray foam or caulk. Blown insulation is also fairly effective at blocking small penetrations like these.
- Around pipes and chimneys. Same fixes.
- Through electrical boxes. The box itself is not always sealed, as there are wires entering it. These can be taped or foamed, but never use foam inside an electrical box.
- Through in-ceiling light fixtures (recessed can lights). Can lights are notoriously leaky, to the point that people often recommend against putting them in exterior ceilings. If you must do a can light, use one with an IC (insulation contact) rated enclosure, and insulate it well. This will minimize leakage without overheating your lights and creating a fire hazard.
If you can inspect your attic for leaks and seal them, you can significantly reduce the ability of insects up there to enter your home. As a bonus, you will also save some money on heating, as the same holes are a great way to lose heat in the winter. Because of this, many utilties (including the MassSave group near Boston) offer free or discounted energy audits and air sealing/insulation services. You might try one of those if it's available to you.
Finally, it isn't normal to have lots of flies living in your attic. It's possible an animal died up there and the flies are feeding on it; cleaning that up (and maybe adding an insect repellent) could help a lot. Although your attic is insulated, you should still be able to move around up there, either by carefully walking on the joists or bringing a board with you that you can put down and stand on. You can also hire a pest control company to do this - ideally one that would clean up, seal any penetrations, and apply insecticides/repellents in one visit.