From 5e0637cba205a2045ffdfdd42424d37ba9bfb3d9 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Volatier <2738857-vjb@users.noreply.gitlab.com> Date: Tue, 17 Jan 2023 09:51:45 +0100 Subject: [PATCH 1/3] nongnu: steam: generate ld.so.conf later This fixes steam-nvidia ld.so.conf --- nongnu/packages/steam-client.scm | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/nongnu/packages/steam-client.scm b/nongnu/packages/steam-client.scm index 08baba8..1880e19 100644 --- a/nongnu/packages/steam-client.scm +++ b/nongnu/packages/steam-client.scm @@ -304,21 +304,6 @@ in the Guix store" fhs-lib-dirs))) #$output))))) -(define steam-ld.so.conf - (packages->ld.so.conf - (list (fhs-union `(,@steam-client-libs - ,@steam-gameruntime-libs - ,@fhs-min-libs) - #:name "fhs-union-64") - (fhs-union `(,@steam-client-libs - ,@steam-gameruntime-libs - ,@fhs-min-libs) - #:name "fhs-union-32" - #:system "i686-linux")))) - -(define steam-ld.so.cache - (ld.so.conf->ld.so.cache steam-ld.so.conf)) - (define (nonguix-container->package container) "Return a package with wrapper script to launch the supplied container object in a sandboxed FHS environment." @@ -561,8 +546,9 @@ application." ;; contains are directly to /gnu/store/. Instead, it could be generated with ;; a generic ld.so.conf and result in paths more typical in an FHS distro, ;; like /lib within the container. This may be useful for future compatibility. - (let* ((ld.so.conf steam-ld.so.conf) - (ld.so.cache steam-ld.so.cache) + (let* ((ld.so.conf (packages->ld.so.conf (list (ngc-union64 container) + (ngc-union32 container)))) + (ld.so.cache (ld.so.conf->ld.so.cache ld.so.conf)) (pkg (ngc-wrap-package container)) (run (ngc-run container))) (program-file From 9f8342c966033ae8491b22388cd97f1827fb77d3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Volatier <2738857-vjb@users.noreply.gitlab.com> Date: Tue, 17 Jan 2023 09:53:42 +0100 Subject: [PATCH 2/3] nongnu: nvidia: add 32bit version of nvidia-driver --- nongnu/packages/nvidia.scm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nongnu/packages/nvidia.scm b/nongnu/packages/nvidia.scm index f4241ca..e248b39 100644 --- a/nongnu/packages/nvidia.scm +++ b/nongnu/packages/nvidia.scm @@ -222,9 +222,13 @@ NVIDIA Management Library") (ice-9 popen) (ice-9 rdelim) (ice-9 regex) + (ice-9 match) (ice-9 textual-ports)) #:install-plan - #~`(("." "lib/" #:include-regexp ("^./[^/]+\\.so") #:exclude-regexp ("nvidia_drv\\.so" "libglxserver_nvidia\\.so\\..*")) + #~`((,(match + #$(or (%current-target-system) (%current-system)) + ("i686-linux" "32") + ("x86_64-linux" ".")) "lib/" #:include-regexp ("^./[^/]+\\.so") #:exclude-regexp ("nvidia_drv\\.so" "libglxserver_nvidia\\.so\\..*")) ("." "share/nvidia/" #:include-regexp ("nvidia-application-profiles.*")) ("." "share/egl/egl_external_platform.d/" #:include-regexp (".*_nvidia_.*\\.json")) ("90-nvidia.rules" "lib/udev/rules.d/") @@ -336,6 +340,7 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $ (symlink (string-append "libnvidia-allocator.so." #$version) (string-append #$output "/lib/nvidia-drm_gbm.so" ))))))) (supported-systems '("x86_64-linux")) + (supported-systems '("x86_64-linux" "i686-linux")) (native-inputs (list patchelf)) (inputs (list `(,gcc "lib") From 7394a512914c9af619dc3476ee193d843308671f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Volatier <2738857-vjb@users.noreply.gitlab.com> Date: Tue, 17 Jan 2023 09:54:51 +0100 Subject: [PATCH 3/3] nongnu: gl: add glvnd support --- nongnu/packages/gl.scm | 129 ++++++++++++++++++++++++++++ nongnu/packages/nvidia.scm | 26 +++++- nongnu/packages/patches/glvnd.patch | 46 ++++++++++ nongnu/packages/steam-client.scm | 14 ++- 4 files changed, 209 insertions(+), 6 deletions(-) create mode 100644 nongnu/packages/gl.scm create mode 100644 nongnu/packages/patches/glvnd.patch diff --git a/nongnu/packages/gl.scm b/nongnu/packages/gl.scm new file mode 100644 index 0000000..aa26039 --- /dev/null +++ b/nongnu/packages/gl.scm @@ -0,0 +1,129 @@ +(define-module (nongnu packages gl) + #:use-module (guix build-system gnu) + #:use-module (gnu packages) + #:use-module (gnu packages audio) + #:use-module (gnu packages freedesktop) + #:use-module (gnu packages gnome) + #:use-module (gnu packages linux) + #:use-module (gnu packages toolkits) + #:use-module (gnu packages graphics) + #:use-module (gnu packages pulseaudio) + #:use-module (gnu packages gtk) + #:use-module (gnu packages autotools) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages python) + #:use-module (gnu packages xorg) + #:use-module (guix packages) + #:use-module (guix gexp) + #:use-module (guix utils) + #:use-module (guix transformations) + #:use-module (gnu packages gl)) + + +(define-public gl-search-path (list + (search-path-specification + (variable "__EGL_VENDOR_LIBRARY_DIRS") + (files '("share/glvnd/egl_vendor.d"))) + (search-path-specification + (variable "__EGL_EXTERNAL_PLATFORM_CONFIG_FILENAMES") + (files '("share/egl/egl_external_platform.d")) + (file-pattern ".*\\.json$") + (file-type 'regular)) + (search-path-specification + (variable "VK_ICD_FILENAMES") + (files '("share/vulkan/icd.d")) + (file-pattern ".*\\.json$") + (file-type 'regular)) + (search-path-specification + (variable "VK_LAYER_PATH") + (files '("share/vulkan/implicit_layer.d"))) + (search-path-specification + (variable "VDPAU_DRIVER_PATH") + (files '("lib/vdpau"))) + (search-path-specification + (variable "GBM_BACKENDS_PATH") + (files '("lib/gbm"))) + (search-path-specification + (variable "GUIX_GL_PATH") + (files (list "lib/glvnd"))))) + +(define-public libglvnd-glfix + (package/inherit + libglvnd + (name "libglvnd-glfix") + (source + (origin + (inherit (package-source libglvnd)) + (patches + (parameterize + ((%patch-path + (map (lambda (directory) + (string-append directory "/nongnu/packages/patches")) + %load-path))) + (search-patches "glvnd.patch"))))))) + +(define-public mesa-glvnd + (package/inherit + mesa + (name "mesa-glvnd") + (arguments + (substitute-keyword-arguments (package-arguments mesa) + ((#:configure-flags flags) + `(cons "-Dglvnd=true" ,flags)) + ((#:phases phases) + #~(modify-phases #$phases + (add-after 'install 'symlink-glvnd + (lambda _ + (mkdir-p (string-append #$output "/lib/glvnd")) + (symlink (string-append #$output "/lib/libGLX_mesa.so.0") + (string-append #$output "/lib/glvnd/libGLX_mesa.so.0")))))))) + (propagated-inputs + `(("libglvnd" ,libglvnd-glfix) + ,@(package-propagated-inputs mesa))) + (description (string-concatenate (list (package-description mesa) " Glvnd-enabled variant."))))) + +(define rewrite-input-glvnd (package-input-rewriting `((,mesa . ,mesa-glvnd) + (,libglvnd . ,libglvnd-glfix)))) + +(define-public (rewrite-glvnd p) + (package + (inherit (rewrite-input-glvnd p)) + (name (string-concatenate (list (package-name p) "-glvnd"))) + (description (string-concatenate (list (package-description p) " Glvnd-enabled variant."))) + (native-search-paths gl-search-path))) + +(define-public libepoxy-glvnd + (rewrite-glvnd libepoxy)) + +(define-public mesa-utils-glvnd + (rewrite-glvnd mesa-utils)) + +(define-public xdg-utils-glvnd + (rewrite-glvnd xdg-utils)) + +(define-public zenity-glvnd + (rewrite-glvnd zenity)) + +(define-public alsa-plugins-glvnd + (rewrite-glvnd alsa-plugins)) + +(define-public imgui-1.86-glvnd + (rewrite-glvnd imgui-1.86)) + +(define-public mangohud-glvnd + (rewrite-glvnd mangohud)) + +(define-public openal-glvnd + (rewrite-glvnd openal)) + +(define-public pulseaudio-glvnd + (rewrite-glvnd pulseaudio)) + +(define-public gtk+-glvnd + (rewrite-glvnd gtk+)) + +(define-public gtk+-2-glvnd + (rewrite-glvnd gtk+-2)) + +(define-public egl-wayland-glvnd + (rewrite-glvnd egl-wayland)) diff --git a/nongnu/packages/nvidia.scm b/nongnu/packages/nvidia.scm index e248b39..428adad 100644 --- a/nongnu/packages/nvidia.scm +++ b/nongnu/packages/nvidia.scm @@ -338,8 +338,30 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $ (symlink (string-append "libglxserver_nvidia.so." #$version) (string-append #$output "/lib/xorg/modules/extensions/" "libglxserver_nvidia.so")) (symlink (string-append "libnvidia-allocator.so." #$version) - (string-append #$output "/lib/nvidia-drm_gbm.so" ))))))) - (supported-systems '("x86_64-linux")) + (string-append #$output "/lib/nvidia-drm_gbm.so" )) + + ;; symlink libGLX_nvidia.so.0 to correct location + + (mkdir-p (string-append #$output "/lib/glvnd")) + (symlink (string-append #$output "/lib/libGLX_nvidia.so.0") + (string-append #$output "/lib/glvnd/libGLX_nvidia.so.0")) + + + ;; and vdpau + (mkdir-p (string-append #$output "/lib/vdpau")) + (symlink (string-append #$output "/lib/libvdpau_nvidia.so") + (string-append #$output "/lib/vdpau/libvdpau_nvidia.so")) + + ;; and gbm + + (when (string=? #$(or + (%current-target-system) + (%current-system)) + "x86_64-linux") + (mkdir-p (string-append #$output "/lib/gbm")) + (symlink (string-append #$output "/lib/libnvidia-egl-gbm.so") + (string-append #$output "/lib/gbm/libnvidia-egl-gbm.so")))))))) + (supported-systems '("x86_64-linux" "i686-linux")) (native-inputs (list patchelf)) (inputs diff --git a/nongnu/packages/patches/glvnd.patch b/nongnu/packages/patches/glvnd.patch new file mode 100644 index 0000000..d4b14d7 --- /dev/null +++ b/nongnu/packages/patches/glvnd.patch @@ -0,0 +1,46 @@ +diff --git a/src/GLX/libglxmapping.c b/src/GLX/libglxmapping.c +index ff2c3a6..3ac21e9 100644 +--- a/src/GLX/libglxmapping.c ++++ b/src/GLX/libglxmapping.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + + #if defined(HASH_DEBUG) + # include +@@ -292,7 +293,33 @@ static char *ConstructVendorLibraryFilename(const char *vendorName) + char *filename; + int ret; + ++ const char* env = NULL; ++ char **tokens; ++ int i; ++ struct stat st; ++ ++ env = getenv("GUIX_GL_PATH"); ++ ++ if (env != NULL) { ++ ++ tokens = SplitString(env, NULL, ":"); ++ ++ if (tokens != NULL) { ++ for (i=0; tokens[i] != NULL; i++) { ++ ret = glvnd_asprintf(&filename, "%s/libGLX_%s.so.0", tokens[i], vendorName); ++ if (ret >= 0) { ++ if (stat(filename, &st) == 0) { ++ free(tokens); ++ ++ return filename; ++ } ++ } ++ } ++ } ++ free(tokens); ++ } ++ + ret = glvnd_asprintf(&filename, "libGLX_%s.so.0", vendorName); + + if (ret < 0) { + return NULL; diff --git a/nongnu/packages/steam-client.scm b/nongnu/packages/steam-client.scm index 1880e19..cce35df 100644 --- a/nongnu/packages/steam-client.scm +++ b/nongnu/packages/steam-client.scm @@ -71,6 +71,7 @@ #:use-module (gnu packages llvm) #:use-module (gnu packages logging) #:use-module (nongnu packages nvidia) + #:use-module (nongnu packages gl) #:use-module (gnu packages pciutils) #:use-module (gnu packages pulseaudio) #:use-module (gnu packages python) @@ -688,6 +689,9 @@ Valve. This package provides a script for launching Steam in a Guix container which will use the directory @file{$HOME/.local/share/guix-sandbox-home} where all games will be installed.")))) +(define nvidia-libs + `(("nvidia-driver" ,nvidia-driver))) + (define-public steam-nvidia (nonguix-container->package (nonguix-container @@ -695,16 +699,18 @@ all games will be installed.")))) (wrap-package steam-client) (run "/bin/steam") (union64 - (replace-mesa + (rewrite-glvnd (fhs-union `(,@steam-client-libs ,@steam-gameruntime-libs - ,@fhs-min-libs) + ,@fhs-min-libs + ,@nvidia-libs) #:name "fhs-union-64"))) (union32 - (replace-mesa + (rewrite-glvnd (fhs-union `(,@steam-client-libs ,@steam-gameruntime-libs - ,@fhs-min-libs) + ,@fhs-min-libs + ,@nvidia-libs) #:name "fhs-union-32" #:system "i686-linux"))) (link-files '("share/applications/steam.desktop"