I’ve only used nix shells via nix-shell -p to temporarily install or try out software. Doing some looking up and ready of stuff like this doesn’t give me answers: https://nixos.org/guides/nix-pills/10-developing-with-nix-shell.html. When I start ComfyUI with uv run pythonmain.py) (NixOS wiki page for uv), I get this error, but not when I run it inside nix-shell -p python313Packages.opencv4Full.
I tried copying the packages the command listed into programs.nix-ld.libraries but that didn’t work.
File "/home/user/Assets/ComfyUI/custom_nodes/comfyui-easy-use/py/nodes/image.py", line 1799, in <module>
import cv2
ImportError: libxcb.so.1: cannot open shared object file: No such file or directory File "/home/user/Assets/ComfyUI/custom_nodes/comfyui-easy-use/py/nodes/image.py", line 1799, in <module>
import cv2
ImportError: libxcb.so.1: cannot open shared object file: No such file or directory
How did you get uv and python in the first place without being in a dev shell?
Installing language toolchains and runtimes via environment.systemPackages does not work as it would on Ubuntu using apt install. The mechanisms behind this are completely different.
And the idea of nixos is to avoid global installation of dev only stuff to battle the problem that Ubuntu and other classic Linux distributions have.
I asked Claude and it listed some packages with nix-ld, which makes the error go away (and the nodes that require opencv seem to be working from a quick test):
No, please use devshells, do not use nix-ld to get libraries for development.
What a patronizing answer, telling me that something that’s been working for me for months without issues is wrong & with no further explanation. You could at least tell me why I should, I literally made this post hoping to expand my understanding of Nix.
You shouldn’t because you use NixOS to not have to do global installation of libraries.
nix-ld itself is a last resort way to get individual packages working, not a dev tool.
You should always try building from source first, then patchelf (automatic or manually), then FHSenv, and only then, if everything before that doesn’t work, then you reach out for nix-ld.
Maybe also valid for a quick “is this software for me, before I put hours of packaging effort”.
Edit: Just so you know the comment above was edited before I wrote this.
I understand that and have almost all my packages in systemPackages. What would a dev shell configuration look like here and would it be just as seamless as the nix-ld config I have right now? (once I’d learn & understand how to use dev shells)