Good news: we did not have to patch libglvnd for the EGL support. All
the low-level machinery was already here (but sadly undocumented).
Bad news: properly supporting the EGL stack turned out being more
involving than its GLX counterpart on the wrapper side. Not only you
need the main EGL lib in charge of implementing the
primitives (libEGL_nvidia.so), but also two other libraries
implementing the wayland and gbm bindings.
These DSOs in turn depend on some non-glibc but open source shared
libraries. I decided to use the ones coming from the host system
rather than the ones provided by Nixpkgs: it's best to assume that the
host system did its homework to determine which version of these
libraries the Nvidia driver is expecting to work with.
First take.
For now, we're only try to support the Nvidia proprietary driver. We
also cut quite some corners :)
We hardcode a list of DSOs we're looking for in the code. That's
obviously the best long-term decision, we'll have to revise this
particular approach later on.
We're looking for these listed DSOs in the GL_VENDOR_PATH provided by
the user. We'll need to patch these DSOs and we obviously don't want
to alter the host OS configuration. So we have to first copy them to
the user XDG cache directory.
Once copied, we alter their runpath to point to the user cache dir:
these DSO can depend on each other.
Finally, we point the patched libglvnd GLX implementation to the cache
dir and replace the current process with the target one.