Skip to content

Commit 74b2481

Browse files
jamesbrinkclaude
andauthored
fix: Bundle fonts and patch Comfyroll for NixOS compatibility (#18)
- 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 <noreply@anthropic.com>
1 parent d7ca2ac commit 74b2481

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ Runtime packages (mutable): <data-directory>/.pip-packages/
9393

9494
A default manager config is created on first run with sensible defaults for personal use (`security_level=normal`, `network_mode=personal_cloud`).
9595

96+
## Known Issues
97+
98+
### Custom Nodes Requiring Patching
99+
100+
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**.
101+
102+
| Node Pack | Issue | Fix |
103+
|-----------|-------|-----|
104+
| Comfyroll Studio (`ComfyUI_Comfyroll_CustomNodes`) | Hardcoded `/usr/share/fonts/truetype` | Patched to use bundled fonts |
105+
106+
**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.
107+
96108
## Bundled Custom Nodes
97109

98110
The following custom nodes are bundled and automatically linked on first run:

nix/packages.nix

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ let
1313
# Template input files (images, audio, etc. for workflow templates)
1414
templateInputs = import ./template-inputs.nix { inherit pkgs; };
1515

16+
# Bundled fonts for custom nodes that require font files
17+
# This provides a pure Nix solution for nodes like ComfyUI_Comfyroll_CustomNodes
18+
# that expect fonts at hardcoded paths like /usr/share/fonts/truetype
19+
bundledFonts = pkgs.symlinkJoin {
20+
name = "comfyui-fonts";
21+
paths = [
22+
pkgs.dejavu_fonts
23+
pkgs.liberation_ttf
24+
pkgs.noto-fonts
25+
pkgs.roboto
26+
];
27+
postBuild = ''
28+
# Create a flat directory with all TTF files for easy access
29+
mkdir -p $out/ttf
30+
find $out/share/fonts -name "*.ttf" -exec ln -sf {} $out/ttf/ \; 2>/dev/null || true
31+
find $out/share/fonts -name "*.TTF" -exec ln -sf {} $out/ttf/ \; 2>/dev/null || true
32+
'';
33+
};
34+
1635
# Import custom nodes for bundling
1736
customNodes = import ./custom-nodes.nix {
1837
inherit
@@ -298,6 +317,32 @@ let
298317
done
299318
fi
300319
320+
# Create fonts directory with bundled fonts for custom nodes
321+
# This provides fonts for nodes like ComfyUI_Comfyroll_CustomNodes that expect
322+
# fonts at hardcoded paths like /usr/share/fonts/truetype (which doesn't exist on NixOS)
323+
FONTS_DIR="$BASE_DIR/fonts"
324+
mkdir -p "$FONTS_DIR"
325+
# Symlink bundled TTF fonts (only if not already linked)
326+
for font_file in "${bundledFonts}"/ttf/*.ttf "${bundledFonts}"/ttf/*.TTF; do
327+
if [[ -e "$font_file" ]]; then
328+
filename=$(basename "$font_file")
329+
target="$FONTS_DIR/$filename"
330+
if [[ ! -e "$target" ]]; then
331+
ln -sf "$font_file" "$target"
332+
fi
333+
fi
334+
done
335+
336+
# Patch custom nodes that use hardcoded font paths for NixOS compatibility
337+
# ComfyUI_Comfyroll_CustomNodes: patch /usr/share/fonts/truetype -> $BASE_DIR/fonts
338+
COMFYROLL_FONT_FILE="$BASE_DIR/custom_nodes/ComfyUI_Comfyroll_CustomNodes/nodes/nodes_graphics_text.py"
339+
if [[ -f "$COMFYROLL_FONT_FILE" ]]; then
340+
if grep -q '"/usr/share/fonts/truetype"' "$COMFYROLL_FONT_FILE" 2>/dev/null; then
341+
sed -i "s|\"/usr/share/fonts/truetype\"|\"$FONTS_DIR\"|g" "$COMFYROLL_FONT_FILE"
342+
echo "Patched ComfyUI_Comfyroll_CustomNodes for NixOS font compatibility"
343+
fi
344+
fi
345+
301346
# Link our bundled custom nodes
302347
# Remove stale directories if they exist but aren't symlinks
303348
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
359404
fi
360405
361406
# Create default ComfyUI-Manager config if it doesn't exist
362-
MANAGER_CONFIG_DIR="$BASE_DIR/user/default/ComfyUI-Manager"
407+
# Note: Manager moved config from user/default/ComfyUI-Manager to user/__manager
408+
MANAGER_CONFIG_DIR="$BASE_DIR/user/__manager"
363409
MANAGER_CONFIG="$MANAGER_CONFIG_DIR/config.ini"
364410
if [[ ! -e "$MANAGER_CONFIG" ]]; then
365411
mkdir -p "$MANAGER_CONFIG_DIR"

0 commit comments

Comments
 (0)