# Contributing to Nails Thanks for helping. Nails aims to feel familiar to Rails developers, so the best changes start from "here's what Rails does" and get as close as Rust allows. ## Setup Contributing to Nails requires [mise](https://mise.jdx.dev/getting-started.html) 2026.11.16 or newer. From a terminal: ```sh git clone https://github.com/wesleygrimes/nails cd nails mise trust mise bootstrap ``` Bootstrap installs the native build tools on macOS and Debian/Ubuntu, sets up Rust from `rust-toolchain.toml`, and builds the workspace. SQLite is bundled. On other Linux distributions, install a C compiler, linker and Bash with your system package manager before bootstrap. ## Make a change Run `mise test nails-cli` to test the CLI crate, or `mise test` for the whole workspace. Use `mise tasks` to list all development commands. Builds go through [mbx](https://mr-boxington.jdx.dev), a compile cache shared by every checkout on your machine. To reclaim space, run `mise tidy`. It removes this checkout's build folder and leftovers from interrupted checks, and the next build restores compiled crates from the cache. If disk space is tight, use `CARGO_PROFILE_TEST_DEBUG=line-tables-only mise test` after cleaning. Test backtraces still show file names and line numbers, but interactive debuggers have less information about local variables. Keep tests lean: one focused test per behavior. Put assertions that need a live Postgres database in `crates/nails/tests/postgres.rs`, which CI runs against Postgres 16. Open an issue first if you propose a new or changed public API, a change to the shape of a generated app (such as its file layout), or a deliberate departure from Rails behavior. A small bug fix that restores clearly expected behavior can go straight to a pull request with a regression test. ## Before a pull request Run `mise check` for formatting, Clippy, and workspace tests. If your change affects generated apps, run the relevant checks. Use `mise e2e` for a SQLite app, `mise e2e:api` for an API-only app, or `mise e2e:postgres` for [Postgres](#postgres). The generated-app checks compile browser tests. To execute them, install Chrome or Chromium and run `cargo test --test system` from a scaffolded app. Set `CHROME_PATH` to the browser executable if needed. ### Postgres The workspace suite skips live Postgres coverage unless `NAILS_TEST_DATABASE_URL` is set. Both integration suites **drop and recreate the database in that URL**, so use a disposable database and a role that can create databases. CI uses Postgres 16. Put the matching `pg_dump` on your PATH for the schema dump test. If you have Docker, you can start a disposable server on port 55432. ```sh docker run --rm -d --name nails-dev-postgres -p 127.0.0.1:55432:5432 \ -e POSTGRES_PASSWORD=postgres postgres:16 ``` Once the server is ready, run the framework and queue suites. Adjust the port and credentials if you use your own server. ```sh NAILS_TEST_DATABASE_URL=postgres://postgres:postgres@localhost:55432/nails_test \ mise test:postgres ``` The Postgres generated-app check creates a fresh pair of databases on localhost for each run and removes them with `dropdb` on exit. Keep `dropdb` and `pg_dump` on PATH. You can reuse the same server across runs. ```sh PGPORT=55432 PGUSER=postgres PGPASSWORD=postgres mise e2e:postgres ``` Stop the disposable container afterward with `docker stop nails-dev-postgres`. ## How the code is laid out | Crate | What it contains | | --- | --- | | [nails](crates/nails/src) | Framework APIs for records, queries, controllers, views, migrations and testing | | [nails-cli](crates/nails-cli/src) | The `nails` executable, commands, generators and templates | | [nails-macros](crates/nails-macros/src) | The `#[nails::model]` procedural macro | | [nails-queue](crates/nails-queue/src) | Database-backed jobs, workers and scheduling | ## Style - Run `mise format` to apply the formatting rules in `rustfmt.toml`. - Match Rails names where you can (`find_by`, `assert_redirected_to`, `db:migrate`), and add a row to the [Rails → Nails tables](docs/rails-to-nails.md) for anything new. - Keep app code synchronous, like Rails. Async stays inside the framework. - Comments explain why, not what. Skip any comment that restates the next line; no comment beats a weak one. ## Pull requests Keep each pull request to one change. Say why it's needed and how you verified it. CI must pass before merge. To bring in changes from `main`, merge `origin/main` into your branch. Don't rebase or force-push a branch that has an open pull request, because that rewrites history reviewers have already seen. Use a [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) title such as `fix: preserve edited migration files` because the PR title becomes the squash commit title. For breaking changes, explain how to upgrade in the PR body. By contributing, you agree that your contributions are dual-licensed under the MIT and Apache 2.0 licenses, as described in the README. This project follows the [Code of Conduct](CODE_OF_CONDUCT.md). ## Contributor credit We credit merged work in the [README](README.md#contributors) using [All Contributors](https://allcontributors.org). To credit someone, leave a comment on an issue or pull request, replacing `@username` with their GitHub handle. ```text @all-contributors please add @username for code ``` Use the [emoji key](https://allcontributors.org/docs/en/emoji-key) to choose the contribution type, such as `doc` for documentation or `bug` for a bug report. The bot opens a pull request with the updated credits.