For the record, after trying a few other things, I went back to two-phased compilation, i.e. first writing the generated source code in a file and then compiling properly. I have, however, added a conditional symbol (-d option to compiler) to first phase and using this, eliminated running most other macros from this phase. This way, I don't have compilation output doubled which was the only annoying thing about running the compiler twice.
While I didn't originally like the idea of adding the generated source file into the codebase, it turned out to be quite useful to have the source there for development. I even committed it into the repo. I love Nim. With every trouble resolved, the overall experience gets only better.
