GrabNim is a simple tool to install and switch between different versions of the Nim compiler.
This project started as a script I wrote out of frustration with choosenim.
Features:
Comparison with choosenim:
Basic Usage:
grabnim # Install latest stable Nim
grabnim fetch # Show available versions for your OS
grabnim 2.2.4 # Install specific version
grabnim compile devel # Install from source
grabnim list # Show installed versions
Installation:
wget https://codeberg.org/janAkali/grabnim/raw/branch/master/misc/install.sh
sh install.sh
Or download from releases and setup PATH env.
Project Page: https://codeberg.org/janakali/grabnim
GrabNim makes it easy to test your code against different Nim versions. Give it a try and let me know what you think!
compile.nim module is heavily-based on nimenv.
I only had to rewire types and some git procs to grabnim internals.
Awesome work!
I was working on something similar myself, but you beat me to it :)
Demo:
If you're using grabnim on Windows - there's a new flag to automatically setup your PATH env:
grabnim setup
It'll confirm if .nimble and grabnim/current directories are already in PATH and ask you for confirmation before adding them.
Great Projrct!
I have tried it and it's much better than choosenim.
but one more suggestion from nodejs https://nodejs.org/en/download/current
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"
# Download and install Node.js:
nvm install 24
# Verify the Node.js version:
node -v # Should print "v24.4.0".
nvm current # Should print "v24.4.0".
# Verify npm version:
npm -v # Should print "11.4.2".
maybe we can do this?
# Download and install nvm (Nim Version Manager):
curl -o- https://codeberg.org/janAkali/grabnim/raw/branch/master/misc/install.sh | bash
# Download and install Nim:
nvm 2.2.4
# Verify theNim version:
nim -v # Should print "v2.2.4".
# Verify nimble version:
nimble -v
Fixes:
Features:
Demo "From Zero to Compiling" (recorded in Wine):
Mozilla's MPL 2.0 seems to be a fitting choice
MPL is the second best thing after GPL.
I'm fine with applications under other licenses using parts of GrabNim code as long as they share all the changes.
This literally describes "virality".
Consider keeping the license at MIT for consistency with Nim to have ease of adoption.
What consistency? Adoption as what? It's an end-user software, not a library.
I'm a user first. The only category of software that haven't ever tried to actively disappoint † me is Free Software. No such luck with permissive-licensed open source.
†: euphemism for "fsck‡ over".
This literally describes "virality".
by "virality" I meant the feature of GPL where if you statically link or include a file / snippet of GPL-licensed code - all other files in the app must be released under GPL license. MPL is applied per file, so you can mix and match licenses more freely.
It's an end-user software, not a library.
You're making an arbitrary distinction. Every Nim module can be used as a library. nimenv.nim, discussed at the start of this thread, is also not a librariy, but I am using parts of it's code in grabnim.
Copyleft is good, but I don't like the virality of GPL. I'm fine with applications under other licenses using parts of GrabNim code as long as they share all the changes.
MPL2 is under used in my opinion. There's cases where letting code be used in propriety applications but still requiriring releasing any modifications to the code itself can be useful.
I'd say something like the core engine of an industrial cad software. It keeps improvements to the core engine open but let's folks create proprietary apps on top.
I just tried grabnim out and it's pretty good! I am having problems trying to run it in a Github Action however. I'm getting:
Failed to get content from 'https://api.github.com/repos/nim-lang/nightlies/releases/tags/latest-version-2-2'. Error:403 rate limit exceeded
This occurs on macos-runners because there still doesn't appear to be an arm64 binary in the release :/ . Grabnim tries to look up the latest latest-2-2 but fails with the 403 rate limit.
Grabnim tries to look up the latest latest-2-2 but fails with the 403 rate limit.
Yeah, this is a known problem. Github API allows only 60 requests per hour per IP for unauthenticated users. So if you're using some shared connection, or in this case - Github Runner, it's too easy to exhaust these limits.
I've updated GrabNim to use GitHub's Personal Access Token for API calls (can be set in GRABNIM_GITHUB_TOKEN env variable). And here's a new section in the README with instructions on how to generate and use this token - https://codeberg.org/janAkali/grabnim#fixing-github-api-403-errors-rate-limits-access-denied
Awesome thanks!
Do you know why installing a release version fails? Say 2.2.4 on macos arm64. I did a quick check but only found the github logic. How are official releases found?
GrabNim scrapes release urls <https://codeberg.org/janAkali/grabnim/src/commit/5474b2da124dc460127f1e02fc392eebfea98cb4/grabnim.nim#L88-L102> from "https://nim-lang.org/install.html" webpage. Then it parses the platform from archive names and compares it to host OS:
# utils/osextra
proc getCompatibleNimOrgOS(): OStype =
case hostOS
of "windows":
case hostCPU
of "amd64": Windows_x64
of "i386": Windows_x32
else: Unknown
of "linux", "macosx", "netbsd", "freebsd", "openbsd":
case hostCPU
of "amd64": Unix_x64
of "i386": Unix_x32
else: Unknown
else: Unknown
Grabnim fails to find 2.2.4 ARM64 release, because nim-lang.org website only has releases for x86(x32) and x64 CPU architecture. But Nightlies do have an arm64 build, so we use it as a fallback for the default "install latest" command.