From aa0e67d631568cb4a666939dd46e74368f80f6f8 Mon Sep 17 00:00:00 2001 From: James Brink Date: Sat, 3 Jan 2026 10:40:15 -0700 Subject: [PATCH] fix: Bundle fonts and patch Comfyroll for NixOS compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add bundled fonts (DejaVu, Liberation, Noto, Roboto) from nixpkgs - Create fonts directory in data dir with symlinked TTF files - Auto-patch ComfyUI_Comfyroll_CustomNodes to use bundled fonts instead of hardcoded /usr/share/fonts/truetype path - Fix ComfyUI-Manager config path (moved to user/__manager/) - Add Known Issues section to README documenting the restart requirement Fixes #17 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- README.md | 12 ++++++++++++ nix/packages.nix | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 82bc788..4974f0f 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,18 @@ Runtime packages (mutable): /.pip-packages/ A default manager config is created on first run with sensible defaults for personal use (`security_level=normal`, `network_mode=personal_cloud`). +## Known Issues + +### Custom Nodes Requiring Patching + +Some custom nodes have hardcoded paths that don't exist on NixOS. We automatically patch these at startup, but **a full service restart is required after installing them via Manager**. + +| Node Pack | Issue | Fix | +|-----------|-------|-----| +| Comfyroll Studio (`ComfyUI_Comfyroll_CustomNodes`) | Hardcoded `/usr/share/fonts/truetype` | Patched to use bundled fonts | + +**After installing these nodes:** Stop ComfyUI completely (Ctrl+C) and restart with `nix run` or `systemctl restart comfyui`. Manager's internal restart does not trigger the patching. + ## Bundled Custom Nodes The following custom nodes are bundled and automatically linked on first run: diff --git a/nix/packages.nix b/nix/packages.nix index e0aee82..333f46b 100644 --- a/nix/packages.nix +++ b/nix/packages.nix @@ -13,6 +13,25 @@ let # Template input files (images, audio, etc. for workflow templates) templateInputs = import ./template-inputs.nix { inherit pkgs; }; + # Bundled fonts for custom nodes that require font files + # This provides a pure Nix solution for nodes like ComfyUI_Comfyroll_CustomNodes + # that expect fonts at hardcoded paths like /usr/share/fonts/truetype + bundledFonts = pkgs.symlinkJoin { + name = "comfyui-fonts"; + paths = [ + pkgs.dejavu_fonts + pkgs.liberation_ttf + pkgs.noto-fonts + pkgs.roboto + ]; + postBuild = '' + # Create a flat directory with all TTF files for easy access + mkdir -p $out/ttf + find $out/share/fonts -name "*.ttf" -exec ln -sf {} $out/ttf/ \; 2>/dev/null || true + find $out/share/fonts -name "*.TTF" -exec ln -sf {} $out/ttf/ \; 2>/dev/null || true + ''; + }; + # Import custom nodes for bundling customNodes = import ./custom-nodes.nix { inherit @@ -298,6 +317,32 @@ let done fi + # Create fonts directory with bundled fonts for custom nodes + # This provides fonts for nodes like ComfyUI_Comfyroll_CustomNodes that expect + # fonts at hardcoded paths like /usr/share/fonts/truetype (which doesn't exist on NixOS) + FONTS_DIR="$BASE_DIR/fonts" + mkdir -p "$FONTS_DIR" + # Symlink bundled TTF fonts (only if not already linked) + for font_file in "${bundledFonts}"/ttf/*.ttf "${bundledFonts}"/ttf/*.TTF; do + if [[ -e "$font_file" ]]; then + filename=$(basename "$font_file") + target="$FONTS_DIR/$filename" + if [[ ! -e "$target" ]]; then + ln -sf "$font_file" "$target" + fi + fi + done + + # Patch custom nodes that use hardcoded font paths for NixOS compatibility + # ComfyUI_Comfyroll_CustomNodes: patch /usr/share/fonts/truetype -> $BASE_DIR/fonts + COMFYROLL_FONT_FILE="$BASE_DIR/custom_nodes/ComfyUI_Comfyroll_CustomNodes/nodes/nodes_graphics_text.py" + if [[ -f "$COMFYROLL_FONT_FILE" ]]; then + if grep -q '"/usr/share/fonts/truetype"' "$COMFYROLL_FONT_FILE" 2>/dev/null; then + sed -i "s|\"/usr/share/fonts/truetype\"|\"$FONTS_DIR\"|g" "$COMFYROLL_FONT_FILE" + echo "Patched ComfyUI_Comfyroll_CustomNodes for NixOS font compatibility" + fi + fi + # Link our bundled custom nodes # Remove stale directories if they exist but aren't symlinks for node_dir in "model_downloader" "ComfyUI-Impact-Pack" "rgthree-comfy" "ComfyUI-KJNodes" "ComfyUI-GGUF" "ComfyUI-LTXVideo" "ComfyUI-Florence2" "ComfyUI_bitsandbytes_NF4" "x-flux-comfyui" "ComfyUI-MMAudio" "PuLID_ComfyUI" "ComfyUI-WanVideoWrapper"; do @@ -359,7 +404,8 @@ let fi # Create default ComfyUI-Manager config if it doesn't exist - MANAGER_CONFIG_DIR="$BASE_DIR/user/default/ComfyUI-Manager" + # Note: Manager moved config from user/default/ComfyUI-Manager to user/__manager + MANAGER_CONFIG_DIR="$BASE_DIR/user/__manager" MANAGER_CONFIG="$MANAGER_CONFIG_DIR/config.ini" if [[ ! -e "$MANAGER_CONFIG" ]]; then mkdir -p "$MANAGER_CONFIG_DIR"