This document exists as a brief introduction to how you can contribute to the Hieratika project. It
includes a guide to getting started and
contributing to main
.
This repository is written in Rust, a high-performance and low-level language with a smart compiler that helps to write reliable and fast software. If you haven't worked with Rust before, take a look at the "New to Rust?" section below!
Unfortunately the complexity of having LLVM available for building this project means that we have to be a bit careful with our environment setup. We recommend using lix to work with the flake configuration included in the repository.
We assume that you are either running on linux or macOS at this stage.
-
Install lix using the lix installer—you will want to say "yes" when asked if you want to enable flakes—and make sure that you can successfully run the
nix
command.curl -sSf -L https://install.lix.systems/lix | sh -s -- install # Follow the instructions nix --version
-
Clone the repository. If you don't want to contribute directly you can use HTTPS clones:
git clone https://github.com/reilabs/hieratika
If you do want to contribute directly to the tree, we recommend cloning over SSH:
git clone git@github.com:reilabs/hieratika.git
-
Enter the cloned directory (
cd hieratika
) and launch a development shell usingnix develop
. This will launch into your default shell, but you can override this by runningnix develop ".#ci" --command <your-command>
to use the CI dev shell instead. -
Within this shell you are able to run Cargo commands such as
cargo build
, which will build the project, orcargo test
which will run the tests.
In order to ensure uniform formatting we use a series of precommit hooks that run things like linters and other checks before things get committed.
- Set Up: Run
npm install
. This will install and set up the hooks that run before every commit. - Test: When you run
git commit
, you will see a progress indicator show up that gives insight into the linting and formatting processes that are running. If any of these fail, then
In order to run these hooks you will either need to be within the nix develop
shell, which
provides all of these, or to have the following installed and available on your path: nodejs
,
npm
and npx
, and both rustfmt
and clippy
.
Due to the complexities of getting some IDEs to work with nix-based Rust projects, we recommend
using a system-wide installation of the correct toolchain (as specified in
Cargo.toml
). Then, we recommend launching your IDE from the
development shell provided by nix develop
, as this will give it the correct environment variables
to find the LLVM install.
We cannot provide instructions for all IDEs out of the box, but please feel free to add instructions for your own IDE or editor here if you are working on the project.
For those using RustRover you will need to go to the top-level "Rust" section in settings, and point both "Toolchain location" and "Standard library" to a system-level install of both. For example:
Toolchain Location = /Users/<you>/.rustup/toolchains/stable-platform-here/bin
Standard library = /Users/<you>/.rustup/toolchains/stable-platform-here/lib/rustlib/src/rust
Specifically do not point to the locations provided by nix
for the development shell, as RustRover
seems to have issues with these.
For contributions this repository works on a Pull Request and subsequent review model, supported by CI to check that things avoid being broken. The process works as follows:
- If necessary, you fork the repository, but if you have access please create a branch.
- You make your changes on that branch.
- Pull-request that branch against
main
. - The pull request will be reviewed, and CI will run on it.
- Once reviewers accept the code, and CI has passed, it will be merged to main!
If you are new to working with Rust, a great place to start is the official Rust Book. It gives a great overview of the language and general style. It's also worth getting familiar with the following tools:
- Rustup, the Rust toolchain installer.
- Cargo, the Rust build tool and package manager.
- docs.rs, a site providing up-to-date crate (package) documentation for all packages published to crates.io, the official package registry.
- Rustdoc, the ecosystem's official documentation tool.
In terms of development tooling, there are two major options in this space.
- Rust Analyzer is the official implementation of the Language Server Protocol for Rust, and will work with any LSP compatible host.
- RustRover is the fully-featured JetBrains IDE for working with Rust in single- and multi-language projects. The Rust support plugin can also run in other JetBrains IDEs if needed.