Recently I've been attempting to contribute to arraymancer - a n-dimensional tensor (ndarray) library written in Nim. While trying to make Windows tests work, I decided to try building Nim from source on Windows.

Nim + Docker + Windows

Building from source on Windows is actually detailed relatively well on the windows install page of the official language site:

Rather than using the zip and exe provided there, I thought I would try writing a Dockerfile to build the language in a more reproducible way: here you can see the Dockerfile source. I did find that building Nim from source differed slightly from the instructions on the README of the language though. After using chocolately to install git, 7zip, and mingw, it boils down to just a few steps in powershell:

# Clone the main repo
git clone
cd Nim

# Clone the csources
git clone --depth 1
cd csources;

# Run the build batch script
cd ..

# Bootstrap the koch helper
bin\nim.exe c koch
.\koch.exe boot -d:release
.\koch.exe tools

# Download the additional dlls to the bin folder
cd bin
Invoke-WebRequest -UseBasicParsing -O

# Unzip them
7z x

# Use the Set-Path.ps1 script to add Nim & Nimble bin dirs to the PATH
.\Set-Path.ps1 -NewLocation "C:\Nim\bin"; `
.\Set-Path.ps1 -NewLocation "$env:USERPROFILE\.nimble\bin";

In the last few lines, the .\Set-Path.ps1 file can be found here - which I took from Peter Hahndorf's blog here. It's actually surprising how many answers and variance there is on trying to add a variable to the PATH variable on windows.

Automating with Appveyor

Thereafter, I wanted to automate the process of pushing a docker image to Docker Hub - and after reading Stefan Scherer's blog post on deploying images using Appveyor - I only had to make one small change:

  - ps: echo $env:DOCKER_PASS | docker login -u="$env:DOCKER_USER" --password-stdin

Without using the --password-stdin docker will raise an error which fails the build. Additionally, you need to prefix the line with ps: to ensure you can access the $env: variables.

Now you can see the image published here:

And you can use it by simply pulling:

docker pull metasyn/nim-servercore