Skip to content

Instantly share code, notes, and snippets.

@ZoomTen
Created July 11, 2023 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZoomTen/05c1cc9e13677ec399c9cfa9e446ca48 to your computer and use it in GitHub Desktop.
Save ZoomTen/05c1cc9e13677ec399c9cfa9e446ca48 to your computer and use it in GitHub Desktop.
How to bootstrap Nim

Building the compiler

Which version do you want to install?

VERSION=v1.6.14

Clone the Nim repo

git clone --depth 1 --branch $VERSION https://github.com/nim-lang/Nim

Clone the csources for an earlier Nim version

cd Nim && git clone --depth 1 https://github.com/nim-lang/csources_v1 csources

Build the csources

pushd csources && sh build.sh

Go back into the Nim directory and compile Koch

popd && bin/nim c koch

Get Koch to compile the newer Nim version

./koch boot -d:release

Your new Nim™ will be in bin/nim. Enjoy!

Building Nimble

Literally just:

./koch nimble

Notes

  • The bottleneck here is compiling Koch; depending on the combination of csources and Nim repo version it may or may not work. Building csources itself however should always work.
  • Nimble at the moment wants to dynamically link with OpenSSL 1.1.
  • You also want cacert.pem to be accessible to Nimble to be able to download packages.
  • I've tested with MSYS2 MinGW64 environment (2023-05-26 snapshot). Works on my machine!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment