-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Using nimscript for configuration
Christopher Dunn edited this page May 21, 2017
·
4 revisions
The [nimscript docs](* https://nim-lang.org/docs/nimscript.html) describe the nimscript API, but I needed some help on how to use it. (Most of the following applies to nimble too, but let's concentrate on nimscript for now.)
Suppose you have a scrDir like this:
src/
foo.nim
foo.nim.cfg
foo.nims
nim.cfg
zzz.nims
Suppose foo.nims
looks like this:
echo "In foo.nims"
include "zzz.nims"
task mybuild, "My build task":
echo "In mybuild"
switch("verbosity", "2")
setCommand "c"
task newtask, "My new task":
echo "In newtask"
setCommand "dump"
And zzz.nims
looks like this:
echo "In zzz.nims"
echo gorge("git rev-parse HEAD")
You could run your nimscript like this: nim e foo.nims
, but that will not make your tasks available.
Instead, run nim on foo.nim
like this:
nim newtask foo
nim mybuild -d:debug foo
All the standard .cfg
files are read before your nimscript. You can use include
to avoid repeating code for each tool-specific .nims
file. That's not quite as convenient as a global nim.cfg
file, but it's more flexible.
Intro
Getting Started
- Install
- Docs
- Curated Packages
- Editor Support
- Unofficial FAQ
- Nim for C programmers
- Nim for Python programmers
- Nim for TypeScript programmers
- Nim for D programmers
- Nim for Java programmers
- Nim for Haskell programmers
Developing
- Build
- Contribute
- Creating a release
- Compiler module reference
- Consts defined by the compiler
- Debugging the compiler
- GitHub Actions/Travis CI/Circle CI/Appveyor
- GitLab CI setup
- Standard library and the JavaScript backend
Misc