Note, if you want easy guarantees that both implementations implement the same functions, you can write yourself a bunch of forward declarations of the procs that should be defined and include those in the various files that provide the different implementations.
#moduleInterface.nim
proc x1(y: string)
proc x2(y: int)
#implementation1.nim
include moduleInterface
proc x1(y: string) = echo "Implementation1 x1"
proc x2(y: int) = echo "Implementation1 x2"
#implementation2.nim
include moduleInterface
proc x1(y: string) = echo "Implementation2 x1"
proc x2(y: int) = echo "Implementation2 x2"
#main.nim
when defined(myFlag):
import implementation1
else:
import implementation2
Note that this only works for procs, not for templates, iterators etc. so that could be an unwelcome limitation for that mechanism.