Skip to content

Instantly share code, notes, and snippets.

@AriFordsham
Last active October 6, 2021 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AriFordsham/cec64463286d267307cedbfc51077679 to your computer and use it in GitHub Desktop.
Save AriFordsham/cec64463286d267307cedbfc51077679 to your computer and use it in GitHub Desktop.
Plutus pioneer program build instructions

You need three dependencies to build a Plutus project:

  • nix
  • git
  • wget
  1. If you don't have git and wget, you'll need to get them from your package manager.

  2. Install nix

    $ curl -L https://nixos.org/nix/install | sh
    
  3. Set up nix to use the IOHK binary caches

    Open /etc/nix/nix.conf in your favorite editor, and add the following to it:

    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=
    
  4. Clone both the Plutus repo and the Pioneer Program repo

    Maybe create a directory to work from:

    $ mkdir plutus && cd plutus
    
    $ git clone https://github.com/input-output-hk/plutus
    $ git clone https://github.com/input-output-hk/plutus-pioneer-program
    
  5. Check out the right commit of Plutus

    Open the file plutus-pioneer-program/code/week01/cabal.project. Find the tag for the Plutus repo. (around line 28)

    source-repository-package
        type: git
        location: https://github.com/input-output-hk/plutus.git
        subdir:
            ...
        tag: ea0ca4e9f9821a9dbfc5255fa0f42b6f2b3887c4
    

    Switch to the Plutus repo and checkout that hash.

    $ cd ../plutus
    $ git checkout ea0ca4e9f9821a9dbfc5255fa0f42b6f2b3887c4
    
  6. Open a nix shell

    Still in the Plutus repo, open a nix shell.

    $ nix-shell
    

    The first time you do this, it will take some time, as it downloads or builds all the dependencies it needs . When it's done, you'll get a shell with all the libraries and tools needed to hack on Plutus. This will be cached, and should open instentaneously on future invocations.

  7. Build the example project

    Still in the nix shell, change into the Week 1 (for example) project directory.

    [nix-shell:~/plutus/plutus]$ cd ../plutus-pioneer-program/code/week01
    [nix-shell:~/plutus/plutus-pioneer-program/code/week01]$ cabal update && cabal build
    

    Once again, the first time this will take some time, but subsequent builds will just rebuild the changes.

BONUS: Start nix-shell from the project directory.

Instead of sitching between dirextories every time you star hacking, you can open the right nix-shell directly from your project directory as follows:

$ nix-shell /path/to/plutus/repo/shell.nix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment