Deadlock Mod Manager
Developer Documentation

Development with Nix

Set up a reproducible development environment using Nix flakes

Development with Nix

For Linux users, we provide a complete Nix flake that sets up your entire development environment with all required dependencies in a reproducible way.

This setup is currently only available on Linux due to Tauri's dependency on GTK and WebKit. After setting up Nix, follow the general Development Setup guide for the remaining steps.

Why Use Nix?

Nix provides several advantages for development:

  • Reproducible: Everyone gets exactly the same environment, eliminating "works on my machine" issues
  • Complete: All system libraries, tools, and dependencies are automatically managed
  • Isolated: Doesn't interfere with your system packages or other projects
  • Automatic: With direnv, the environment activates when you enter the project directory

Installation

Install Nix

If you don't have Nix installed, follow the official installation guide:

Make sure to enable experimental features (flakes and nix-command) by adding this to ~/.config/nix/nix.conf:

experimental-features = nix-command flakes

direnv automatically loads and unloads environment variables based on your current directory:

sudo apt install direnv
sudo pacman -S direnv
Install through your config or nix-shell

Then add the hook to your shell config:

Add to ~/.bashrc:

eval "$(direnv hook bash)"

Add to ~/.zshrc:

eval "$(direnv hook zsh)"

Add to ~/.config/fish/config.fish:

direnv hook fish | source

Quick Start

Clone and Enable

Clone the repository and enable the Nix environment:

git clone https://github.com/deadlock-mod-manager/deadlock-mod-manager.git
cd deadlock-mod-manager
direnv allow

The environment will be automatically loaded when you enter the directory. All system dependencies are now available!

nix develop

This opens a new shell with all dependencies available. Run this every time you want to work on the project.

Continue with General Setup

Now follow the Development Setup guide for:

  • Installing pnpm dependencies
  • Setting up the database
  • Starting the development server

All system dependencies (Rust, Node.js, GTK, WebKit, etc.) are already provided by Nix!

What's Included?

The Nix flake automatically provides:

Development Tools

  • Rust toolchain (stable latest) with rust-analyzer and clippy
  • Node.js 22 with pnpm 9 and bun
  • Code quality tools: biome, turbo, lefthook

System Libraries

All required libraries for Tauri development:

  • GTK3 and WebKit2GTK 4.1
  • GStreamer (for media playback)
  • Cairo, Pango, GDK-PixBuf
  • OpenSSL, bzip2

Database & Services

  • PostgreSQL client tools
  • Redis client tools
  • Docker & Docker Compose

Build Tools

  • gcc, make, pkg-config
  • cargo-watch, cargo-edit
  • CLI utilities: ripgrep, fd, jq

Building the Nix Package

You can build a standalone Nix package of the desktop application:

# Build the nightly package
nix build .#nightly

# The built application is available in ./result
./result/bin/deadlock-mod-manager

# Or build and run directly
nix run .#nightly

This produces a fully self-contained package with all dependencies included.

Formatting Nix Files

Format all Nix files in the project using:

nix fmt

This uses nixpkgs-fmt to ensure consistent formatting.

Environment Variables

The Nix development shell automatically sets up several environment variables:

VariableValuePurpose
DATABASE_URLpostgresql://turborepo:123456789@localhost:5435/turborepoDatabase connection
REDIS_URLredis://localhost:6379Redis connection
NODE_ENVdevelopmentNode.js environment
CARGO_HOME$PWD/.cargoCargo cache directory
RUST_BACKTRACE1Enable Rust backtraces
WEBKIT_DISABLE_COMPOSITING_MODE1WebKit optimization

Troubleshooting

Environment Not Loading

Problem: The environment isn't activating automatically

Solution:

  • Ensure you ran direnv allow in the project directory
  • Verify direnv is properly hooked in your shell config
  • Try running direnv reload to force a refresh

Hash Mismatch Errors

Problem: Build fails with "hash mismatch" errors

Solution:

  • The dependency hashes in package.nix may need updating
  • Check the GitHub Actions CI logs for the correct hashes
  • The CI automatically updates hashes when dependencies change

Nix Store Out of Space

Problem: Nix store is consuming too much disk space

Solution:

# Remove old generations and collect garbage
nix-collect-garbage -d

# For more aggressive cleanup
nix store gc --verbose

CI/CD Integration

The project uses GitHub Actions to:

  • Automatically update dependency hashes (pnpm)
  • Test the Nix build on every PR
  • Verify the development shell loads correctly
  • Build and cache the nightly package

See .github/workflows/nix-test.yml for the complete CI configuration.

Additional Resources

Contributing to the Nix Setup

If you find issues or want to improve the Nix configuration:

  1. Open an issue describing the problem or enhancement
  2. Submit a PR with changes to flake.nix or package.nix
  3. Ensure nix flake check passes
  4. Test both development shell and package builds

The Nix configuration is actively maintained and we welcome contributions!

On this page