How to install Nimrod on OS X

Setup Nimrod with OS X 10.9.2 Mavericks using brew.

brew install nimrod

That was painless but unfortunately there is a weird issue with getting a symbolic link to run nimrod from /usr/local/bin. This can be avoided by using a simple shell script. Save this as /usr/local/bin/nimrod.


#!/bin/sh
exec /usr/local/Cellar/nimrod/0.9.2/libexec/bin/nimrod "$@"

Note: Be sure to update your nimrod path above to point to the right directory if different from version 0.9.2.

Don’t forget to make the script executable:

chmod u+x /usr/local/bin/nimrod

And now let’s give this a little test run. Save the following piece of code as helloword.nim:

echo("Hello world!")

We can try running it now with the following command:

nimrod compile --run hellworld.nim

If all went well, then you should have a compiled version of hellworld.nim saved as a helloworld binary in the same folder. The --run argument in the command obviously runs the program so it should have outputted “Hello world!” at the end.

Commonly used arguments have abbreviations. You can write the above compile line like so:

nimrod c -r hellworld.nim

Now take off with the nimrod tutorials!

Apr 7, 2014 Programming