A Nix flake for Fooocus - an image generating software focused on simplicity.
- Cross-platform: Linux (x86_64, aarch64) and macOS (Intel, Apple Silicon)
- Reproducible builds with Nix
- Automatic GPU detection (NVIDIA CUDA, Apple Silicon MPS, CPU fallback)
- Persistent data storage in
~/.config/fooocus - Docker images (CPU and CUDA variants)
- Multiple preset support (default, anime, realistic)
Run Fooocus directly without installation:
nix run github:utensils/fooocus-nixOr with a specific preset:
nix run github:utensils/fooocus-nix#anime
nix run github:utensils/fooocus-nix#realisticAdd to your flake.nix:
{
inputs.fooocus-nix.url = "github:utensils/fooocus-nix";
}Then use the overlay or package:
# Using the overlay
nixpkgs.overlays = [ fooocus-nix.overlays.default ];
# Or directly reference the package
environment.systemPackages = [ fooocus-nix.packages.${system}.default ];git clone https://github.com/utensils/fooocus-nix
cd fooocus-nix
nix develop # Enter development shell
nix run # Run Fooocus# Run with default settings
nix run .
# Open browser automatically when ready
nix run . -- --open
# Use a specific port
nix run . -- --port=7866
# Listen on all interfaces (for network access)
nix run . -- --listen 0.0.0.0
# Use a preset
nix run . -- --preset=anime
# Enable debug logging
nix run . -- --debug| Command | Description |
|---|---|
nix run |
Run Fooocus with default preset |
nix run .#anime |
Run with anime preset |
nix run .#realistic |
Run with realistic preset |
nix run .#buildDocker |
Build CPU Docker image |
nix run .#buildDockerCuda |
Build CUDA Docker image |
nix run .#update |
Check for Fooocus updates |
Build and run the Docker image:
# CPU version
nix run .#buildDocker
docker run -p 7865:7865 -v $PWD/data:/data fooocus:latest
# CUDA version (requires nvidia-container-toolkit)
nix run .#buildDockerCuda
docker run --gpus all -p 7865:7865 -v $PWD/data:/data fooocus:cudaFooocus stores persistent data in ~/.config/fooocus:
~/.config/fooocus/
├── app/ # Fooocus application code
├── venv/ # Python virtual environment
├── models/ # Downloaded models
│ ├── checkpoints/ # Main model files
│ ├── loras/ # LoRA models
│ ├── embeddings/ # Text embeddings
│ ├── controlnet/ # ControlNet models
│ └── ...
└── outputs/ # Generated images
The flake automatically detects your GPU:
- NVIDIA: Uses CUDA (cu124 by default, configurable via
CUDA_VERSIONenv var) - Apple Silicon: Uses Metal Performance Shaders (MPS) acceleration
- Intel Mac: Falls back to CPU-only mode
- CPU: Falls back to CPU-only mode on any platform
Override CUDA version:
CUDA_VERSION=cu121 nix run .Supported CUDA versions: cu118, cu121, cu124, cpu
On M1/M2/M3/M4 Macs, PyTorch automatically uses MPS (Metal Performance Shaders) for GPU acceleration. No additional configuration is required.
Note: First run will download macOS-specific PyTorch wheels which may take a few minutes.
nix developThis provides:
- Python 3.12 environment
- Development tools (git, shellcheck, shfmt)
- Linting tools (ruff, pyright)
- Nix formatting (nixfmt-rfc-style)
# Run all checks
nix flake check
# Individual checks
nix run .#lint # Python linting
nix run .#format # Python formatting
nix run .#type-check # Type checking
nix run .#check-all # All Python checksFooocus is tracked as a flake input, so updating to HEAD is simple:
nix flake update fooocus-srcIf port 7865 is already in use, the launcher will offer options to:
- Open browser to existing instance
- Use a different port
- Kill the process using the port
If CUDA isn't detected despite having an NVIDIA GPU:
- Ensure NVIDIA drivers are installed
- Check that
nvidia-smiworks - Try setting
CUDA_VERSIONexplicitly
The first run downloads:
- Python dependencies
- PyTorch with appropriate GPU support
- Base models (automatically on first generation)
Subsequent runs use cached dependencies.
This issue is now handled automatically by the flake. The launcher sets the path_outputs environment variable to bypass Gradio's symlink security restrictions.
If you still encounter {"detail":"File not allowed: .../log.html"}, manually edit ~/.config/fooocus/app/config.txt:
"path_outputs": "/home/YOUR_USER/.config/fooocus/outputs"Change from .../app/outputs to the real path (without the app/ symlink), then restart Fooocus.
This project contains two components with different licenses:
- Packaging code (Nix expressions, shell scripts): MIT License - see LICENSE
- Fooocus application: GPL-3.0 - see the Fooocus repository
The Nix package metadata reflects GPL-3.0 as that is the license of the packaged software.
- Fooocus by lllyasviel