Aside from some custom wiring and electrical add-ons, the most critical issue the generator/alternator/stator. Many dirt bikes don't have the electrical system as standard to supply running voltage to support running headlight.
A bit trickier than you think...
If I'm wrong, an electrical expert will chime in to provide guidance otherwise.