This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build the package
nix build
# Run Fooocus
nix run # Default preset
nix run .#anime # Anime preset
nix run .#realistic # Realistic preset
# Run all CI checks (package build, shellcheck, nixfmt)
nix flake check
# Enter development shell
nix develop
# Format Nix files
nix fmt
# Docker images
nix run .#buildDocker # Build CPU image
nix run .#buildDockerCuda # Build CUDA image
# Check for upstream Fooocus updates
nix run .#updateThis is a Nix flake that packages Fooocus for reproducible deployment. The flake uses a hybrid approach: Nix handles environment setup and packaging, while pip manages Python dependencies at runtime.
-
Runtime pip installation: Python dependencies are installed via pip into a venv at
~/.config/fooocus/venvon first run, not at Nix build time. This allows GPU-specific PyTorch versions to be detected and installed dynamically. -
Nix variable substitution: Shell scripts use
@varName@placeholders thatpkgs.replaceVarssubstitutes at build time. Onlyconfig.shandlauncher.shhave substitutions; other scripts are copied directly. -
Persistent data: All user data lives in
~/.config/fooocus/with symlinks from the app directory. Models, outputs, and venv persist across updates.
launcher.sh (entry point)
→ sources config.sh (sets paths, parses args)
→ sources logger.sh (logging utilities)
→ sources install.sh (creates venv, installs deps)
→ sources persistence.sh (sets up symlinks)
→ sources runtime.sh (starts Fooocus via launch.py)
- Inputs:
nixpkgs,flake-utils,fooocus-src(non-flake GitHub source) - Version: Derived from
fooocus-src.shortRev(git short hash) - Packages:
default(main),dockerImage(CPU),dockerImageCuda(CUDA) - Apps:
default,anime,realistic,buildDocker,buildDockerCuda,update, linting apps - Checks:
package,shellcheck,nixfmt
Gradio blocks file access through symlinks. The flake handles this by setting the path_outputs environment variable to the real path (~/.config/fooocus/outputs) before Fooocus starts. This ensures Gradio's allowed_paths uses the correct path for network file serving.
If users still report "File not allowed" for log.html, they can manually edit ~/.config/fooocus/app/config.txt and change path_outputs to ~/.config/fooocus/outputs.
Fooocus source is tracked as a flake input, so updating is simple:
nix flake update fooocus-srcThis fetches the latest HEAD from GitHub. The version shown will be the git short rev (e.g., ae05379).