In fruit flies, sex is determined primarily by:
Fruit fly sexual fate depends upon counting X chromosomes relative to autosome ploidy, not Y. In XX embryos double dose of X-encoded numerator transcription factors SisA, SisB, Scute and Runt activate early Sex-lethal promoter SxlPe around cycle 12. Resulting Sxl protein maintains female splicing program and inhibits dosage compensation complex. In XY embryos single dose fails to activate Sxl, causing male-specific splicing of downstream effectors and activation of MSL complex for X hypertranscription. Y chromosome provides fertility factors such as kl-5 for spermatogenesis but does not influence male versus female identity.
Ref: Gilbert, Developmental Biology, 12th ed., Chapter 7: Drosophila sex determined by X chromosome number.