Took me a bit of reading and trying, but at the end it is very easy to write a "Makefile" (or "task.py" file or similar) in Nim:
Just create a config.nims file and list the tasks there. The trick then is that you run the compiler command (`nim`) to execute these tasks.
No additional make or invoke task runner executable needed. Pretty simple and elegant - when you know it!
A big thanks to all the people making Nim what it is!
Ok, here a small example of my "tasks" setup for Nim as I use it at the moment. This is probably not the best way to do these things but it is the result of how I understand NimScript:
A minimal config.nims looks like this:
#
# NimScript build file for Project X
#
# Switches
switch("verbosity", "0")
switch("hints", "off")
when defined(testing) :
switch("verbosity", "1")
switch("hints", "on")
#
# Tasks
#
task tests, "run the test":
exec "testament pat \"test*.nim\""
task build, "build project":
exec "nim c main.nim"
Having this config file in your project root you can test your project with
nim tests
and you built it with
nim build
Note: The not-so-obvious part might be to use the compiler command nim to execute your tasks. No separate task runner command like make, invoke or an imagined nimscript is needed.