Plutus Pioneers - Weekly Environment Setup with git and nix-shell

Week 2 Lecture 2 is upon us, Plutus Pioneers! In order to follow along, you’ll need to update your work environment. You’ll likely need to follow these steps for each subsequent week.

Checkout this Week’s Revision

Last week you cloned and built the plutus-apps repository on your computer. Consider the plutus-apps directory your launch point for coursework. It was within this context that you built and executed the Plutus Playground Server and its client.

This first step is a little hairy. Hang on tight…

Judging by the steps taken in Week 1, you’ll likely need to rebuild the Playground client and server every new week. To do this, you must checkout the correct revision of the plutus-apps repository. You can determine the revision number by consulting the plutus-pioneer-program repository.

Using the code for Week 2 as an example, look for the code/week02/cabal.project file. You will find the required revision number under the source-repository-package > tag configuration. Week 2’s revision number looks like this: 6aff97d596ac9d59460aab5c65627b1c8c0a1528.

Get ready to copy/paste that number. But first, navigate to the plutus-apps directory. For me, this step looks like this:

1
cd ~/workspace/plutus-apps

Update the repository in case there were any recent changes:

1
2
git checkout main
git pull

Now, checkout the correct revision:

1
git checkout 6aff97d596ac9d59460aab5c65627b1c8c0a1528

Phew! I don’t know for sure, but I suspect you’ll need to do this every week.

Rebuild and Execute the Plutus Playground

This assumes that you were successful in setting up nix.

Continuing from above, execute:

1
nix-build -A plutus-playground.server

Start nix-shell:

1
nix-shell

Start the Plutus Playground Server:

1
2
cd plutus-playground-server/
plutus-playground-server

The server should now be executing in the foreground of your terminal. Leave this open. Open a second terminal window and start the client (steps consolidated here):

1
2
3
4
cd ~/workspace/plutus-apps/
nix-shell
cd plutus-playground-client
npm run start

Now the client is running. You can see it at https://localhost:8009 in your favourite browser. Leave this terminal open as well.

Update the Course Code and Get to Work

Open a new terminal window and start nix-shell:

1
2
cd ~/workspace/plutus-apps/
nix-shell

By now, it should be clear that the plutus-apps directory contains what you need to get the provided environment up and running. Now, navigate to your plutus-pioneers-program directory:

1
cd ../plutus-pioneers-program

Update the local repository:

1
git pull

You now have this week’s lesson material. Navigate to the directory and build the project:

1
2
cd code/week02/
cabal build

Time for me to start watching the new lectures