How are people using libglvnd with mesa as the vendor? I notice mesa
does not include -Dglvnd=true, and thus no libEGL_mesa.so or
libGLX_mesa.so is built.

My solution is to create my own mesa-with-glvnd package, add it to
LD_LIBRARY_PATH is my profile, and tell libglvnd to use mesa as the
vendor.

I don't think this is a good solution. Building mesa with glvnd would
help, but I'm not sure how I can avoid something like LD_LIBRARY_PATH to
locate libGLX_mesa.so.

My solution looks like the following. First with the mesa-with-glvnd
package, followed by my home configuration.

    (define-module (sijo packages gl)
      #:use-module (gnu packages gl)
      #:use-module (guix gexp)
      #:use-module (guix packages)
      #:use-module (guix utils))
    
    (define-public mesa-with-glvnd
      (package
        (inherit mesa)
        (name "mesa-with-glvnd")
        (propagated-inputs
          (modify-inputs (package-propagated-inputs mesa)
            (prepend libglvnd)))
        (arguments
          (substitute-keyword-arguments (package-arguments mesa)
            ((#:configure-flags flags #~'())
             #~(cons* "-Dglvnd=true" #$flags))
            ((#:phases phases #~%standard-phases)
             #~(modify-phases #$phases
                 (add-after 'install 'patch-egl-vendor-file
                   (lambda _
                     (substitute* (string-append #$output 
"/share/glvnd/egl_vendor.d/50_mesa.json")
                       (("libEGL_mesa.so.0") (string-append #$output 
"/lib/libEGL_mesa.so.0")))))))))))
    

      ;; libglvnd with mesa as vendor
      (simple-service 'mesa-as-libglvnd-vendor
                      home-environment-variables-service-type
                      ;; We add it to the library path so e.g. libGLX_mesa.so
                      ;; can be found even though the packages only use
                      ;; libglvnd.
                      `(("LD_LIBRARY_PATH" . ,(file-append mesa-with-glvnd 
"/lib"))
                        ("__GLX_VENDOR_LIBRARY_NAME" . "mesa")
                        ("__EGL_VENDOR_LIBRARY_DIRS" . ,(file-append 
mesa-with-glvnd "/share/glvnd/egl_vendor.d"))))

Attachment: signature.asc
Description: PGP signature

Reply via email to