Hello, I have a long compilation command like this:

nim c -r -o=../build -d:myUglyVariable:"myUglyValue" main.nim --loglevel=DEBUG

I'd like to move all that in nim.cfg, or at least that ugly variable, so that I type just

nim c -r main.nim
Is that possible? I really lack any docs on nim.cfg file syntax.

2018-03-11 13:42:59
A long long time ago we had this crazy thing called shell scripts. We used them to set environmental variables, build complicated command lines, etc... 2018-03-12 01:09:39

Yes you can, feel free to check Arraymancer nim.cfg:


@libman: Unfortunately shell scripts would not work on all Windows for example.

2018-03-12 07:31:52

@mratsim Cool, thank you very much! Definitely saw that file earlier but VS Code underlines some lines in red so I thought something was wrong... But it works!

# nim.cfg

@Libman Sure, but I didn't want to touch shell scripts at all. Not only cause they are ugly but also I think nim itself pushes us towards using nim.cfg for persistent configuration and nimble for package-level tasks. And yes, it's os-independent.

2018-03-12 20:40:17
@Arrrrrrrrr thx, super handy! Can't understand why .cfg configs aren't deprecated though 2018-03-13 12:52:21

.cfg config helpful when all you need just simply additional options.

Just name the cfg like "yourmodule.nim.cfg" and Nim compiler will only use that option when you try to compile "yourmodule.nim", it won't be used when you compile "anothermodule.nim".

2018-03-13 12:55:55