B&M (Busch und Müller) (and other companies catering the european market) have some battery powered taillights which can be mounted directly to light mounts on racks. you could also look into e-bike rear lights for racks and connect them to a battery. And then there are rear lights which allow mounting on a back pack or saddle bag, so you could attach those as well to the rack. Or you get a mount to attach your light directly below the saddle. there are some adapter for saddle rails.