Skip to main content

Nix development environment

Nix is an alternative to Docker Compose for backend development. Instead of running PostgreSQL, Redis, and MinIO inside containers, the Nix dev shell installs pinned versions of those services (and Python, ruff, and the build toolchain) from the Nix store and runs them directly on your host. Service data lives in a project-local .nix-data/ directory.

If you would rather use the standard Docker-based workflow, see the backend setup guide.

note

This environment is for backend (care) development. It targets macOS and non-NixOS Linux — the automated setup script intentionally refuses to run on NixOS, which should use NixOS-specific configuration instead.

Prerequisites

  1. Install Nix. The Determinate Systems installer is preferred — it provides a cleaner install and hassle-free uninstallation:

    curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
  2. Enable flakes. Modern installers enable flakes automatically. If yours did not, add the following to ~/.config/nix/nix.conf:

    experimental-features = nix-command flakes
  3. Optional — install direnv for automatic shell activation when you cd into the repo:

    # macOS (Homebrew)
    brew install direnv

    # Linux (varies by distribution)
    sudo apt install direnv # Ubuntu/Debian
    sudo dnf install direnv # Fedora

    Then, from the repo root:

    echo "use flake" > .envrc
    direnv allow

Automated setup

For a first-time setup, run the setup script from the repo root:

./scripts/nix-dev-setup.sh

The script checks that Nix is installed and flakes are enabled, creates the Python virtual environment and installs dependencies, starts the services (PostgreSQL, Redis, MinIO), runs migrations, and optionally loads sample fixtures.

Quick start (manual)

To set things up by hand, enter the dev shell and run the in-shell commands:

nix develop
setup-dev
start-services
rundev

This enters the development environment, installs Python dependencies into a .venv, starts the background services, runs migrations, and launches the unified development server (Django API plus Celery worker).

tip

Background services persist between shell sessions. On later days you usually only need nix develop, then start-services (if not already running), then rundev.

In-shell commands

Once you are inside the dev shell (nix develop), these commands are on your PATH:

GroupCommandDescription
Servicesstart-servicesStart PostgreSQL, Redis, and MinIO
Servicesstop-servicesStop the background services only
Serviceskill-careStop all development processes and services
ServerrundevStart the API server and Celery worker together (recommended)
ServerrunserverStart the Django development server only
ServerceleryStart the Celery worker with beat scheduler only
DatabasemigrateRun database migrations
Databaseload-fixturesLoad sample data
Databasereset-dbDrop and recreate the database
TestingtestRun the test suite (reuses the database)
Testingtest-coverageRun tests and produce a coverage report
QualityruffLint and fix staged Python files
Qualityruff-allLint all Python files
note

Additional helpers are available in the shell, including makemigrations, manage <command>, dump-db, load-db, clean-data, healthcheck, test-no-keep, and ruff-fix-all. The dev shell prints the full list when you enter it.

Service URLs

After start-services and rundev are up:

ServiceURL / addressNotes
Django applicationhttp://localhost:9000API and admin
MinIO consolehttp://localhost:9001S3-compatible object storage UI
PostgreSQLlocalhost:5432Database
Redislocalhost:6379Cache and Celery broker
info

Default development credentials (for example the MinIO and database logins) are set automatically by the dev shell and are intended for local use only. Services bind to localhost and are not reachable externally.

How it differs from Docker

The Nix workflow produces the same database schema, migrations, and Python dependency versions as the Docker setup — the two can coexist. The main differences:

  • Services run on the host, not inside containers, so there is no container overhead and startup is faster.
  • Data lives in .nix-data/ (postgres/, redis/, minio/) instead of Docker volumes. This directory is added to .gitignore automatically.
  • Commands run directly in the shell — there is no docker compose exec indirection.
  • Versions are pinned by the flake (for example Python 3.13 and PostgreSQL 15 from the Nix store), so the toolchain is reproducible across machines.