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 flakesInstall direnv (Recommended)
direnv automatically loads and unloads environment variables based on your current directory:
sudo apt install direnvsudo pacman -S direnvThen 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 | sourceQuick 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-managerdirenv allowThe environment will be automatically loaded when you enter the directory. All system dependencies are now available!
nix developThis 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 .#nightlyThis produces a fully self-contained package with all dependencies included.
Formatting Nix Files
Format all Nix files in the project using:
nix fmtThis uses nixpkgs-fmt to ensure consistent formatting.
Environment Variables
The Nix development shell automatically sets up several environment variables:
| Variable | Value | Purpose |
|---|---|---|
DATABASE_URL | postgresql://turborepo:123456789@localhost:5435/turborepo | Database connection |
REDIS_URL | redis://localhost:6379 | Redis connection |
NODE_ENV | development | Node.js environment |
CARGO_HOME | $PWD/.cargo | Cargo cache directory |
RUST_BACKTRACE | 1 | Enable Rust backtraces |
WEBKIT_DISABLE_COMPOSITING_MODE | 1 | WebKit optimization |
Troubleshooting
Environment Not Loading
Problem: The environment isn't activating automatically
Solution:
- Ensure you ran
direnv allowin the project directory - Verify direnv is properly hooked in your shell config
- Try running
direnv reloadto force a refresh
Hash Mismatch Errors
Problem: Build fails with "hash mismatch" errors
Solution:
- The dependency hashes in
package.nixmay 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 --verboseCI/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:
- Open an issue describing the problem or enhancement
- Submit a PR with changes to
flake.nixorpackage.nix - Ensure
nix flake checkpasses - Test both development shell and package builds
The Nix configuration is actively maintained and we welcome contributions!