asdf with Nix on macOS

April 25, 2022

In the past I have used nvm, pyenv, and rvm for managing multiple installs of programming language runtimes for NodeJS, Python, and Ruby respectively. I recently did a clean format and this time around am going to try asdf which takes a stab at being a single tool for this purpose.

The asdf installation instructions on macOS assume Homebrew is used to install some dependencies. I generally favour using Nix instead, so the instructions below are how I got it to work instead.

Before executing any of the command line statements below it would be best to check each source first to make sure they are current as they could and most likely will change over time.

Step 1: Install Nix on macOS

$ sh <(curl -L

Step 2: Install asdf

There are multiple installation options offered for asdf, the one I picked was ZSH & Git:

$ git clone ~/.asdf --branch v0.10.0

And then I added the following to the ~/.zshrc file:

# 2022-04-25:, manages installs such as Node
. $HOME/.asdf/

Step 3: Install asdf Node dependencies with Nix

$ nix-env -i gpgme gawk

Step 4: Install the asdf Node plugin

$ asdf plugin add nodejs

Step 5: Install a specific Node version with asdf

$ asdf install nodejs 16.14.2

Step 6: Set specific Node version as global

$ asdf global nodejs 16.14.2

Step 7: Make sure everything worked

$ node --version