NimScript and Build Automation

NimScript = a subset of Nim interpreted by the compiler's VM. Used for config.nims, .nimble files, and standalone scripts.

Available: exec, gorgeEx, cpFile, mvFile, mkDir, rmDir, listFiles, listDirs, existsEnv, getEnv, switch, paramStr, withDir, selfExec, projectDir().

Limitations: no FFI, no ptr, no threads.

Embedding NimScript in your app as a scripting engine: the nimscripter package (or compiler-as-library).

#!/usr/bin/env -S nim e --hints:off
# build.nims
mode = ScriptMode.Verbose
task build, "Build the project":
  exec "nim c -d:release -o:bin/app src/app.nim"
task clean, "Clean":
  rmDir "bin"
  for f in listFiles("."):
    if f.endsWith(".log"): rmFile f
echo "Current dir: ", getCurrentDir()
nim e build.nims
nim build        # tasks defined in config.nims can be run as `nim taskName`