Hi
@Rojif Eggs, larvae, and pupa, will all live in the top inches of the soil. They will need moisture and fungal spores to survive. By simply allowing the top 2 inches of your medium to dry out between waterings, you will make it harder for the fungus gnats to live there.
At the very least, this will massively reduce the amount of bugs in the grow room. Most cases of bugs and pests can be put down to bad waterting practise. It is vital, especially when growing with soil or organically, to allow the medium to dry out a little between waterings. Good luck mate ๐๐