Commit c18dbf1
Pure Nix Flake Refactor (#12)
* chore: finalize flake cleanup
* chore: simplify flake check sources
* docs: align README and CLAUDE with modes
* refactor: modularize flake.nix into separate nix/ modules
- Split 837-line flake.nix into focused modules (~160 lines now):
- nix/versions.nix: Version pins for ComfyUI and vendored wheels
- nix/python-overrides.nix: Python package customizations
- nix/vendored-packages.nix: PyPI wheel packages
- nix/packages.nix: Main package derivation
- nix/docker.nix: DRY Docker image builder with mkDockerImage helper
- nix/apps.nix: App definitions using writeShellApplication
- nix/checks.nix: CI check definitions
- nix/modules/comfyui.nix: Full NixOS systemd service module
- NixOS module features:
- listenAddress option (default 127.0.0.1, use 0.0.0.0 for network)
- Automatic user/group creation
- Firewall integration
- Mutable mode support
- tmpfiles.rules for directory management
- Improvements:
- Use stdenv.mkDerivation instead of buildPythonApplication
- Add meta.maintainers to package
- Add passthru for introspection
- Use replaceVars consistently
- Remove Cachix references (not used)
- Fix $PWD escaping in app scripts
- Document all NixOS module options in README
* fix: model downloader path and workflow-templates dependencies
- Fix model downloader being installed with Nix store hash prefix
by copying contents into properly named directory
- Add missing workflow-templates dependencies:
- comfyui-workflow-templates-core
- comfyui-workflow-templates-media-api
- comfyui-workflow-templates-media-video
- comfyui-workflow-templates-media-image
- comfyui-workflow-templates-media-other
- Refactor vendored-packages.nix with mkWheel helper function
* fix: enable template input downloads in pure mode
Template input files (images, videos) are static assets needed for
workflow examples to function properly. These should be downloaded
regardless of mode, as they don't modify code - they're just
media files referenced by workflow templates.
* feat: sync docker fixes and update ComfyUI 0.5.1
* Improve flake packaging and docs
* Use Nix python runtime for pyright
* Ignore data and scope pyright to src
* Add CUDA app and runtimes
* Align CUDA python deps with torchWithCuda
* Document Cachix cache usage
* Update CI for flake-refactor-pure and Cachix
* Fix pyright typing for model downloader handlers
* Fix Cachix conditionals in CI
* Free disk space before Docker build
* Ensure model_downloader dir is writable before relinking
* Default COMFY_MODE to pure on all platforms
* Fix pure frontend path and gate CUDA on Darwin
* Fix MPS FP8 dequantization and Darwin deps
* Restore av on Darwin and align ffmpeg deps
* Fix pure-mode reinstall when source changes
* Remove mutable mode and make flake fully pure
This commit removes all mutable mode support from the flake, simplifying
the codebase by eliminating ~300 lines of code related to venv creation,
pip installs, ComfyUI-Manager, and dynamic GPU detection.
## Nix Changes
- nix/apps.nix: Remove `mutable` app and `mutableScript`
- nix/packages.nix: Remove `COMFY_MODE` env var and `comfy` CLI wrapper
- nix/modules/comfyui.nix: Remove `mutable` option from NixOS service
- nix/docker.nix: Remove `COMFY_MODE`, `CUDA_VERSION` env vars and venv
path references
## Script Changes
- scripts/config.sh: Remove mutable-specific variables (COMFY_MODE,
CUDA_VERSION, COMFY_VENV, COMFY_MANAGER_DIR, MODEL_DOWNLOADER_PERSISTENT_DIR),
BASE_PACKAGES/ADDITIONAL_PACKAGES arrays, and mutable path logic
- scripts/install.sh: Remove 4 mutable-only functions (~170 lines):
- install_comfyui_manager() - ComfyUI-Manager git clone/update
- install_model_downloader() - mutable persistent install
- detect_pytorch_version() - runtime GPU detection
- setup_venv() - Python venv creation and pip installs
- scripts/persistence.sh: Remove mutable-specific symlinks for
ComfyUI-Manager and model_downloader
## Documentation
- README.md: Update modes section, features, environment variables,
NixOS module options table, and remove all mutable mode references
- CLAUDE.md: Simplify to reflect pure-only operation
## What Remains
- Pure mode: All Python dependencies provided by Nix
- CUDA support: Via `nix run .#cuda` (Nix-provided CUDA PyTorch)
- Model downloader: Bundled into CODE_DIR (works in pure mode)
- Frontend: Packaged from Nix, no runtime downloads
- Docker images: CPU and CUDA variants, both pure
All `nix flake check` validations pass.
* Document ffmpeg version conflict on Darwin
On Darwin, av uses ffmpeg 7.x and torchaudio uses ffmpeg 6.x. These
versions are mutually incompatible:
- av 14.1.0 requires ffmpeg 7.x+ (uses AV_HWDEVICE_TYPE_D3D12VA)
- torchaudio 2.5.1 requires ffmpeg 6.x (uses deprecated channel_layout API)
The runtime warning about duplicate Objective-C classes is unavoidable
until nixpkgs updates torchaudio to a ffmpeg 7-compatible version.
The warning is harmless in practice.
* Simplify launcher with writeShellApplication and fix startup issues
Major refactoring to follow Nix best practices:
- Replace ~700 lines of bash scripts with ~50 line inline launcher using writeShellApplication
- Run ComfyUI directly from Nix store using native --base-directory and --front-end-root flags
- Remove scripts/ directory (no longer needed)
- Remove src/persistence/ module (ComfyUI handles paths natively)
Fixes:
- Add --database-url to store SQLite DB in user data dir (not read-only Nix store)
- Fix model_downloader symlink to handle stale directories
- Remove .disabled file blocking model_downloader from loading
- Patch comfy_api_nodes canary to skip PyAV version check (API nodes need external credentials anyway)
Cleanup:
- Remove Docker cross-compile from Darwin (kornia-rs platform issues, CI builds on Linux)
- Simplify apps.nix with conditional Docker app exports
- Update documentation for new architecture
* Gate python extras by platform and disable manager in pure mode
* Add comfyui Cachix to flake nixConfig
* Switch Cachix cache name to comfyui
* Override av to 14.2.0 for comfy_api_nodes compatibility
Instead of patching out the PyAV version check, override the av package
to version 14.2.0 which passes the canary check natively. This allows
all comfy_api_nodes (OpenAI, Stability, Runway, etc.) to load properly
for users who have the required API credentials.
* Refactor flake for pure Nix best practices and platform support
Platform-specific improvements:
- Use ~/Library/Application Support/comfy-ui on macOS (Apple convention)
- Use ~/.config/comfy-ui on Linux (XDG convention)
- Set DYLD_LIBRARY_PATH only on macOS, LD_LIBRARY_PATH only on Linux
- Extract --port from args for browser opening (fixes hardcoded 8188)
NixOS module improvements:
- Add systemd security hardening (NoNewPrivileges, ProtectSystem, etc.)
- Add GPU access via video/render supplementary groups
- Clarify createUser option behavior in documentation
- Improve service description
Code quality fixes:
- Fix pyright --pythonpath argument (remove /bin/python suffix)
- Document COMFY_ALLOW_MANAGER environment variable
Documentation sync:
- Update CLAUDE.md and README.md with platform-specific paths
- Add COMFY_ALLOW_MANAGER to environment variables section
- Update NixOS module option descriptions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Improve flake purity and Docker reproducibility
- Add releaseDate to versions.nix for deterministic Docker timestamps
- Use releaseDate instead of "now" in docker.nix for reproducible images
- Fix source filter to exclude all result* symlinks (not just "result")
- Add xdg-utils to launcher runtimeInputs on Linux for --open flag
- Remove redundant Features section from README
Docker images now show the actual ComfyUI release date (2025-12-18)
instead of build time, ensuring reproducible builds while maintaining
meaningful timestamps in `docker images` output.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Streamline README to essentials
Reduce from 481 to 119 lines while preserving all key information:
quick start, options, installation, NixOS module, Docker, and
development commands.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Remove internal packages and redundant dev apps
- Remove pythonRuntime/pythonRuntimeCuda from public packages (internal only)
- Remove lint, lint-fix, format, type-check, check-all apps
- Users can use `nix develop` for ruff/pyright or `nix flake check` for CI
- Pass pythonRuntime directly to checks.nix instead of via packages
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add CI workflow for flake checks
Runs nix flake check on push/PR to validate:
- Package builds
- Python linting (ruff)
- Python type checking (pyright)
- Nix formatting (nixfmt)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Use native ARM runners for aarch64 Docker builds
Switch from QEMU emulation to GitHub's native ARM runners
(ubuntu-24.04-arm) for much faster aarch64-linux builds.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Consolidate CI and Docker workflows
- Merge flake check into main CI workflow
- Run checks before Docker builds (builds depend on check passing)
- Remove separate ci.yml
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* remove un-needed slash commands (claude)
* Add declarative custom nodes support for NixOS module
- Add customNodes option to services.comfyui for pure, reproducible
custom node management via fetchFromGitHub or local paths
- Add preStart script to symlink declared nodes before service start
- Create nix/lib/custom-nodes.nix as foundation for future curated nodes
- Fix .gitignore lib/ pattern to not exclude nix/lib/
- Fix nixfmt check deprecation warning (use find instead of directory)
- Update README and CLAUDE.md with custom nodes documentation
Usage:
services.comfyui = {
enable = true;
customNodes = {
ComfyUI-Impact-Pack = pkgs.fetchFromGitHub {
owner = "ltdrdata";
repo = "ComfyUI-Impact-Pack";
rev = "v1.0.0";
hash = "sha256-...";
};
};
};
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Remove flake-refactor-pure branch references from CI
Clean up CI workflow to only target main branch and version tags,
preparing for merge to main.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 6beef06 commit c18dbf1
File tree
39 files changed
+1378
-4742
lines changed- .claude/commands
- .github/workflows
- docs
- nix
- lib
- modules
- patches
- scripts
- src
- custom_nodes/model_downloader
- persistence
39 files changed
+1378
-4742
lines changedThis file was deleted.
0 commit comments