Diamond Tusks
Diamond Tusks's Blog

Diamond Tusks's Blog

Nix Shell Installation Guide for Macs with M1 Chips

Nix Shell Installation Guide for Macs with M1 Chips

Diamond Tusks's photo
Diamond Tusks
·Apr 26, 2022·

2 min read

This is specifically for new Plutus Developers following the Plutus Pioneer Program, that are having issues with their Nix Shell set up on Macs with M1 Chips. Though I hope that it can also be useful to others.

I had a lot of issues trying to start Nix Shell after a successful installation on my Macbook 2020 M1. As it turns out, apparently some Nix expressions have not yet been prepared for M1 chips.

Here is what I have added to the nix.conf to make it to work:

substituters        = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
system = x86_64-darwin
# system = aarch64-darwin
extra-platforms = x86_64-darwin aarch64-darwin

The first 2 lines is to set up the IOHK binary caches on non-NixOs machines. The other 2 is apparently what is needed for nix shell to run on Macs with M1 chips.

If you are having the same issues, here is what you need to do. (If you have successfully installed Nix then skip 'Install Nix' below and continue with 'Set up the IOHK binary caches'.)

To Install Nix

Open terminal and type:

sh <(curl -L https://nixos.org/nix/install)

Follow the instructions that appear on the terminal.

Ones finished, check if Nix is installed properly by checking the version:

nix --version

To Set Up The IOHK Binary Caches

Edit /etc/nix/nix.conf

Here are steps on how to edit using vim:

In terminal type

sudo vim /etc/nix/nix.conf

Click 'i' to edit and add the 5 lines mentioned above.

Ones edited, save and exit by pressing 'esc' then 'ZZ' (hold shift and press 'zz').

After this nix-shell should run. Keep in mind that the initial nix-shell takes a while because it needs to build anything that isnt cached.

Here are my main sources, its worth your time to go through these also: reddit.com/r/cardano/comments/mmzut6/macos_.. stackoverflow.com/questions/68854559/is-my-.. github.com/NixOS/nixpkgs/issues/95903#issue..

Share this