Conversation
- 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 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
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.
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.
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.
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
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.
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>
- 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>
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 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>
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>
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>
- 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>
- 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>
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>
Resolved conflicts by keeping flake-refactor-pure changes: - Discarded main's shell script updates (scripts removed in pure refactor) - Kept pure Nix flake.nix structure - Kept streamlined README.md and CLAUDE.md - Kept .gitignore with .codex/ instead of .deciduous/ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a comprehensive refactor of the ComfyUI Nix flake to follow pure Nix best practices. The flake has been completely restructured for maintainability, reproducibility, and proper NixOS integration.
Key Changes
Architecture Refactor
flake.nixinto separate files undernix/:packages.nix- Main package with inline launcher usingwriteShellApplicationapps.nix- Flake apps (default, cuda, update, buildDocker, buildDockerCuda)checks.nix- Flake checks (ruff, pyright, nixfmt)docker.nix- Docker image builders with reproducible timestampsversions.nix- All version pins in one placepython-overrides.nix- Python package overridesvendored-packages.nix- Vendored wheel packagesmodules/comfyui.nix- NixOS service module with systemd hardeninglib/custom-nodes.nix- Foundation for declarative custom nodesRemoved Legacy Code
scripts/*.sh) - functionality now in pure Nixsrc/persistence/- no longer needed with--base-directoryapproachnix flake checkinsteadNew Features
services.comfyui.customNodesfor pure, reproducible custom node management~/.config/comfy-ui, macOS uses~/Library/Application Support/comfy-uicreatedtimestamp instead of"now"ubuntu-24.04-armrunners instead of QEMU emulationCI/CD Improvements
docker.ymlnix flake checkto CI pipelineDocumentation
Breaking Changes
nix runinsteadpythonRuntimepackage no longer exposed (internal use only)nix flake checkornix developMigration Guide
Data migration: Copy your data from old location to new:
~/.config/comfy-ui/~/Library/Application Support/comfy-ui/Custom nodes: For NixOS users, use the new declarative option:
Running: Use
nix run github:utensils/comfyui-nix -- --openTest Plan
nix flake checkpasses (ruff, pyright, nixfmt, package build)nix buildsucceeds for default packagenix build .#cudasucceeds for CUDA packagenix build .#dockerImagesucceedsnix build .#dockerImageCudasucceedsStats
🤖 Generated with Claude Code