This is a rather unusual scenario but is it compliant with the NEC to have a light fixture installed in a door that moves, e.g. an attic hatch? I have a hatch to my attic in the middle of a closet ceiling. Was curious if I can have Romex run to an electrical box on the attic side of that hatch, which would then move when the hatch is opened.
Nothing in NEC section 410 prohibits the placement of a luminaire in or on a door or hatch. However, you'll want to use a flexible cord pigtail with strain reliefs between a fixed junction box and the movable door as NM cable is not designed for repeated bending. (Flexible cord is allowed here by 400.7(A)(9), BTW.)