Why? Because I want to compile a 3D model and not Nim completely. The thing is that OCCT requires you to compile a 3D model... This is happening in C++ but thanks to @mantielero we now have https://github.com/mantielero/occt.nim (... which isn't perfect yet).
So you need to compile a nim program to compile a 3D model. Perfect, but I only want to compile the unit and not the program because of the time that is involved with compiling.
Can I only compile the unit / module but not the complete program?
I confess to not being 100% sure what you mean by the "module and not the program", but maybe nim cpp -c foo.nim to only generate ".cpp" files or nim cpp --noLinking=on foo.nim to stop at a forest of ".o/.obj" files in your nimcache are what you are after? (Both are revealed by nim --advanced or nim --fullhelp)
You may also be able to speed up backend compilation by changing your user/project/file .cfg or .nims to use gcc.cpp.options.debug = "-g3 -O0" -O0 rather than the default same but with -Og. The -Og is really just trying to make generated object code "fast without "compromising the debugging experience" according to the interpretation of the gcc folks. ( Of course, not needing C++ on the backend and using tcc is the way to get the fastest compiles, but it sounds like in this situation that is unlikely to be ok. )
Nim usually performs caching, which means it only re-compiles those files that have been changed since the last time you build the project. In my experience, most of the building time was spent on linking, so I think you can switch the linker to a faster one, like mold.
Another option is to prevent the use of macros and templates (though I don't recommend it), thus to reduce the compilation time for a bit.
To be honest it's still not clear to me what the situation is.
You have a Nim module which generates a STEP model at compile time?
Sounds like a weird situation, but anyways could you run the module as nimscript using nim e? That's what happens when you compile a module, compile time code is evaluated as nimscript by the Nim VM.
You have a Nim module which generates a STEP model at compile time?
Yes, this is how OCCT compiles it's 3D files and they have plenty of examples to show how to do it but prefer Nim of course.
Can you link an example that does this compile-time only behavior?
I had a look at: https://github.com/mantielero/occt.nim/blob/main/examples/bottle.nim
From what I can tell, there is no compile-time code in there. It generates the STEP file in main() at runtime. You could compile it once, and run it as many times as required.