`autoPatchelfHook` and `libcuda.so.1`?

Is there a way to tell autoPatchelf to ignore only a specific set of missing dependencies? It seems that autoPatchelfIgnoreMissingDeps = true; allows any dependency to be missing. But in some situations it’s advantageous to only allow a certain dependency to be missing.

For example, libcuda.so is provided by the nvidia-x11 driver in /run/opengl-driver/lib, and so it is usually added with addOpenGLRunpath. But from the perspective of autoPatchelfHook this means that it’s usually missing at build-time. Is there any way to allow it to be missing while enforcing all other libraries to be present?


Perhaps even better would be a mechanism to tell autoPatchelfHook that it should resolve libcuda.so.1 to /run/opengl-driver/lib. Is that possible?

1 Like

In this case I suppose we could do a separate patchelf call.

I’m not sure if that will fix things for us since /run/opengl-driver/lib is not available at build time so I think libcuda.so.1 will still show up as missing. Maybe I’m misunderstanding?

It occurs to me that another way to solve this would be to use addAutoPatchelfSearchPath. But that would mean we’d need to find a way to create /run/opengl-driver/ in the nix-build environment.

Going through the Python implementation auto-patchelf.py it seems the rpath is built from scratch. Thus, we need to invoke patchelf ourselves after this hook.

I’d like to avoid manually patchelf’ing if possible since it’s so easy to miss something that way. In addition, some of the packages need to use wrapQtAppHook as well which complicates matters.

I created auto-patchelf: more precise dependency ignorance by samuela · Pull Request #167397 · NixOS/nixpkgs · GitHub to help solve this.

For future reference, the current recommended way to do this is autoAddOpenGLRunpathHook.