From the fun of experience here is what I do about em
1" sand on top of the top soil, they cant go into you soil to breed and feed on yer roots (this does alot)
also just the other day I found out some Zero Tolerence (that I had to get for mold on another) does a hell of a job of making gnats not want anything to do with the area.
I washed out my sprayer and went to spray water on a clone and the gnats had a fit and never returned to the cabinet I had the clone it (3 days so far so good, and no sand)