Hi,
Last week I had trouble installing plutus playground on MacOS Monterey, whereas it was fine when I followed this guide when I’m still on Big Sur. Mac still have compatibility issues recently because they’re still transitioning to their new M1 chip (i.e issues with Nixpkg).
Granted that plutus is highly under development right now, and things always change in their new release and updates.
After 2 days of trial and error last week, I find some workaround that is working on my machine with MacOS Monterey. So I’m here to write a guide that is hopefully will enable any Mac users out there who’s using M1 chip, to be able learn plutus and follow along Plutus Pioneer #2
MacBook Pro 13" M1 (2020)
MacOS Monterey 12.0.1
8 GB RAM
256GB storage
Setting up nix and plutus environment
- Install nix Download | Nix & NixOS
curl -L https://nixos.org/nix/install | sh - Edit /etc/nix/nix.conf file and add this line from IOHK binary cache
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=
- This is only for M1 user, inside /etc/nix/nix.conf add this line (Reference)
# system = aarch64-darwin
system = x86_64-darwin
extra-platforms = x86_64-darwin aarch64-darwin
Update the env with running this on terminal nix-env -iA nixpkgs.nix
- Restart computer (THIS IS IMPORTANT, in order for nix to restart their daemon tools, and source the nix.conf file)
- Open terminal and clone plutus repo
git clone https://github.com/input-output-hk/plutus.git - Inside plutus directory, switch to commit
git checkout 34aa9c323ed6da68a11f41d41d5aca9f469aaf4b - In the same directory (plutus root folder), build the Plutus Core library
nix build -f default.nix plutus.haskell.packages.plutus-core.components.library - Build the dependencies for Plutus server and client (Reference, step 10 and 11)
- Build the Plutus Playground Client / Server
nix-build -A plutus-playground.client
nix-build -A plutus-playground.server
- Build other plutus dependencies
nix-build -A plutus-playground.generate-purescript
nix-build -A plutus-playground.start-backend
nix-build -A plutus-pab
- Run
nix-shellin this current folder. It will took quite a while the first time running nix-shell - If bash error arise
- If any error arises, refer to this guide
- Done
Workflow for following weekly course from Plutus Pioneer Program:
Plutus Pioneer Program - Iteration #2
General idea:
- Only run nix-shell within
34aa9c323ed6da68a11f41d41d5aca9f469aaf4bcommit, other commit will result in unexpected error or long GHC build for some reason (i.e when running nix-shell withea0ca4e9f9821a9dbfc5255fa0f42b6f2b3887c4) - Set up 3 terminals at the start, and run nix-shell in each of them
- After we’re inside nix-shell, we can navigate freely to different commit of each week
- Before running
plutus-playground-serverandnpm run startinside nix-shell and plutus/plutus-playground-client/ folder, you must runcabal updateandcabal buildinside each corresponding week - If you want to move on to week02 for example, then you have to switch plutus/ repo to commit hash specified inside cabal.project (tag), after that run
cabal updateandcabal buildinside ../plutus-pioneer-program/src/week02/ directory - Do this every time you’re switching week, no need to get out of nix-shell.
- Next time you wanted to get into nix-shell again, make sure to follow again from step 1
Detailed guide (Read the general idea to fully understand the workflow)
- Clone plutus-pioneer-program outside of plutus folder
git clone https://github.com/input-output-hk/plutus-pioneer-program.git - Change directory into plutus, switch to this commit
git checkout 34aa9c323ed6da68a11f41d41d5aca9f469aaf4b - Run nix-shell
- Open 2 other terminal and run
nix-shellin each of them (** Terminal 1 and terminal 2 will be used for running server and client instances, while terminal 3 will be used for navigating inside plutus-pioneer-program folder **) - In terminal 3, while inside nix-shell, navigate to ../plutus-pioneer-program/code/week01
- open cabal.project, and look for
tag, copy the commit hash - In terminal 1,
git checkout ea0ca4e9f9821a9dbfc5255fa0f42b6f2b3887c4 - In terminal 3, while still in /week01 folder, run
cabal update, thencabal build. It will take quite a while - In terminal 1 and terminal 2, change directory to plutus/plutus-playground-client/
- In terminal 1, run
plutus-playground-server
- In terminal 2, run
npm run start
- If some error happen in terminal 2, try it again. Sometimes it’s working the second time for me
- Open your browser, and enter to localhost:8009
- Playground should be able to run locally
- terminal
- simulating and evaluating the codes
- playground







