graphql-engine/v3/CONTRIBUTING.md
Daniel Harvey ce4dd596fb Add instructions for using the Nix Flake (#547)
<!-- Thank you for submitting this PR! :) -->

## Description

We maintain a Nix Flake for installing project dependencies but do not
advertise or explain it. Hopefully this fixes that.

---------

Co-authored-by: Samir Talwar <samir.talwar@hasura.io>
V3_GIT_ORIGIN_REV_ID: f1c5d471a5d1ffd5fa3ef31a471da7fcc44a935b
2024-05-10 12:27:48 +00:00

2.1 KiB

V3 Contributing Guide

Getting Started

Using Docker

Start a development container (which includes NDC agents for testing):

docker compose run --build --rm dev_setup bash

Without Docker

You will need to install some packages:

  • The Rust compiler
  • protobuf-compiler

For development, you may need to install some additional tools such as nextest. See the Dockerfile.

Building the source

If the dependencies are correctly installed as above, you should now be able to run

cargo build

From here, you can follow the instructions in <README.md> to set up a working server.

Installing project dependencies with Nix

We maintain a Nix Flake that will install all of the project dependencies required to work on v3-engine.

To use it:

  1. Install Nix
  2. Run nix develop in the project root. This starts a new shell which exposes the Nix project dependencies on your $PATH, and can be exited with exit.
  3. Type echo $IN_NIX_SHELL to confirm you're in a Nix shell. It should print "impure".
  4. Run which rustc to verify that the Rust compiler is being provided by Nix. You should see a path starting with /nix/store/ and ending in /bin/rustc.

We also supply configuration for direnv to allow autoloading the Nix dependencies upon entering the project folder.

To use this:

  1. Install direnv:
  2. Install the direnv program
  3. Add the direnv hook to your shell
  4. Open a new terminal
  5. cp .envrc.local.example .envrc.local
  6. Run direnv allow
  7. Nix should now install project dependencies and put them in your $PATH whenever you enter the project folder.
  8. Type echo $IN_NIX_SHELL to confirm you're in a Nix shell. It should print "impure".
  9. Run which rustc to verify that the Rust compiler is being provided by Nix. You should see a path starting with /nix/store/ and ending in /bin/rustc.

Architecture

See the architecture document.