|
13 | 13 | # Template input files (images, audio, etc. for workflow templates) |
14 | 14 | templateInputs = import ./template-inputs.nix { inherit pkgs; }; |
15 | 15 |
|
| 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 | + |
16 | 35 | # Import custom nodes for bundling |
17 | 36 | customNodes = import ./custom-nodes.nix { |
18 | 37 | inherit |
|
298 | 317 | done |
299 | 318 | fi |
300 | 319 |
|
| 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 | +
|
301 | 346 | # Link our bundled custom nodes |
302 | 347 | # Remove stale directories if they exist but aren't symlinks |
303 | 348 | 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 | 404 | fi |
360 | 405 |
|
361 | 406 | # 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" |
363 | 409 | MANAGER_CONFIG="$MANAGER_CONFIG_DIR/config.ini" |
364 | 410 | if [[ ! -e "$MANAGER_CONFIG" ]]; then |
365 | 411 | mkdir -p "$MANAGER_CONFIG_DIR" |
|
0 commit comments