Terrier uses devenv for development environment management, which provides:
- Reproducible development environments
- Automatic service management (PostgreSQL, Redis, MinIO)
- Pre-commit hooks
-
Nix (package manager)
Install Nix using the Determinate Systems installer (recommended for macOS/Linux):
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
Follow https://github.com/nix-darwin/nix-darwin to install nix-darwin (for macOS), which the rest of this doc uses. Then run the below to update when you make a change to the flake:
sudo darwin-rebuild switch --flake /etc/nix-darwin
Or see nixos.org/download for other options, including for WSL.
-
devenv (development environment manager)
It's recommended to add
pkgs.devenvto your Nix environment. On nix-darwin, you can find the relevant file in/etc/nix-darwin/.environment.systemPackages = with pkgs; [ devenv ];
Or see devenv.sh/getting-started for all of the installation methods.
-
direnv (automatically load the environment)
Once again, it's recommended to do this in your Nix environment:
programs.direnv = { enable = true; nix-direnv.enable = true; };
Or see direnv.net/getting-started for all of the installation methods.
-
Install the recommended VS Code extensions.
You may have a prompt from the
direnvextension asking you to allow the environment, which you should accept. -
Allow
direnvin your terminal:direnv allow
This will download and build the necessary development environment. It may take a while.
-
Create the environment variables:
cp example/.env.dev .env
Then, edit the
.envfile to set the necessary environment variables. You need to setOIDC_CLIENT_SECRETand changeADMIN_EMAILSto your Andrew email.Configure your development OIDC client with the following redirect URIs:
- Web:
http://localhost:8080/auth/callback - Mobile:
terrier://auth/callback
- Web:
-
Start the development server:
just dev
This starts all services (PostgreSQL, Redis, MinIO) in the background and launches the Dioxus development server with hot reloading. Visit http://localhost:8080 to see the application.
Run just to see all available commands:
Available recipes:
attach # Display service logs
clean # Clean devenv state (removes all service data)
dev # Start development server
down # Stop development server
fresh # Fresh database (drop all tables and reapply migrations)
generate-entities # Generate entities from database
help # Show this help message
init # Start database, run migrations, and generate entities
migrate # Run database migrations
new-migration NAME # Create new migration
status # Check migration statusEvery time you make a change to devenv.nix, you should rebuild the development environment:
direnv reload