I've had fungus gnats problem with MJ grow, also tried various fruit and herbal oils without any satisfactory results. They are pretty persistent little buggers and even survived ACTELLIC pesticide application, though numbers had dwindled.
In the end - adjusting watering habits finally did it for me, and also physically separating plants to different rooms, so that you have multiple small areas to fight them, rather than one big happy bug playground
I made sure that at least top 2 cm of soil is dry before watering, so water less frequently but bigger volume of liquid helps to make their life considerably harder.
I've never grown cacti though.