nongnu: nvidia-driver: Adjust package style.
* nongnu/packages/nvidia.scm (nvidia-driver)[arguments]<#:phases>: Remove $ORIGIN from RUNPATH. Ungexp properly. Rewrite configuration substitution. Rename phase ‘install-nvidia-smi’ to ‘install-commands’. Relocate libraries in a separate phase. Remove extra spaces. <#:install-plan>: Adjust accordingly. [description]: Remove final newline. Signed-off-by: John Kehayias <john.kehayias@protonmail.com>
This commit is contained in:
parent
2b4dfe83e9
commit
5b0465cf31
|
@ -144,44 +144,46 @@ VERSION as argument and returns a G-expression."
|
||||||
(arguments
|
(arguments
|
||||||
(list #:modules '((guix build copy-build-system)
|
(list #:modules '((guix build copy-build-system)
|
||||||
(guix build utils)
|
(guix build utils)
|
||||||
(ice-9 ftw)
|
|
||||||
(ice-9 popen)
|
(ice-9 popen)
|
||||||
(ice-9 rdelim)
|
(ice-9 rdelim)
|
||||||
(ice-9 regex)
|
(ice-9 regex)
|
||||||
(ice-9 textual-ports))
|
(ice-9 textual-ports)
|
||||||
|
(srfi srfi-26))
|
||||||
#:install-plan
|
#:install-plan
|
||||||
#~`((,#$(match (or (%current-target-system) (%current-system))
|
#~`((#$(match (or (%current-target-system) (%current-system))
|
||||||
("i686-linux" "32")
|
("i686-linux" "32")
|
||||||
("x86_64-linux" ".")
|
("x86_64-linux" ".")
|
||||||
(_ "."))
|
(_ "."))
|
||||||
"lib/" #:include-regexp ("^./[^/]+\\.so") #:exclude-regexp ("nvidia_drv\\.so" "libglxserver_nvidia\\.so\\..*"))
|
"lib/" #:include-regexp ("^./[^/]+\\.so"))
|
||||||
("." "share/nvidia/" #:include-regexp ("nvidia-application-profiles.*"))
|
("." "share/nvidia/" #:include-regexp ("nvidia-application-profiles"))
|
||||||
("." "share/egl/egl_external_platform.d/" #:include-regexp (".*_nvidia_.*\\.json"))
|
("." "share/egl/egl_external_platform.d/" #:include-regexp ("(gbm|wayland)\\.json"))
|
||||||
("90-nvidia.rules" "lib/udev/rules.d/")
|
("90-nvidia.rules" "lib/udev/rules.d/")
|
||||||
("nvidia-drm-outputclass.conf" "share/x11/xorg.conf.d/")
|
("nvidia-drm-outputclass.conf" "share/X11/xorg.conf.d/")
|
||||||
("nvidia-dbus.conf" "share/dbus-1/system.d/")
|
("nvidia-dbus.conf" "share/dbus-1/system.d/")
|
||||||
("nvidia-smi.1.gz" "share/man/man1/")
|
|
||||||
("nvidia.icd" "etc/OpenCL/vendors/")
|
("nvidia.icd" "etc/OpenCL/vendors/")
|
||||||
("nvidia_drv.so" "lib/xorg/modules/drivers/")
|
|
||||||
("nvidia_icd.json" "share/vulkan/icd.d/")
|
("nvidia_icd.json" "share/vulkan/icd.d/")
|
||||||
("nvidia_layers.json" "share/vulkan/implicit_layer.d/")
|
("nvidia_layers.json" "share/vulkan/implicit_layer.d/"))
|
||||||
(,(string-append "libglxserver_nvidia.so." #$version) "lib/xorg/modules/extensions/"))
|
|
||||||
#:phases
|
#:phases
|
||||||
#~(modify-phases %standard-phases
|
#~(modify-phases %standard-phases
|
||||||
(delete 'strip)
|
(delete 'strip)
|
||||||
(add-after 'unpack 'create-misc-files
|
(add-after 'unpack 'create-misc-files
|
||||||
(lambda* (#:key inputs #:allow-other-keys)
|
(lambda* (#:key inputs #:allow-other-keys)
|
||||||
;; Vulkan layer configuration
|
;; EGL external platform configuraiton
|
||||||
(for-each (lambda (file)
|
(substitute* '("10_nvidia_wayland.json"
|
||||||
(substitute* file
|
"15_nvidia_gbm.json")
|
||||||
(("lib(GLX|nvidia).*\\.so\\..*" all)
|
(("libnvidia-egl-(wayland|gbm)\\.so\\.." all)
|
||||||
(string-append #$output "/lib/" all))))
|
(string-append #$output "/lib/" all)))
|
||||||
(scandir "." (lambda (name)
|
|
||||||
(string-contains name ".json"))))
|
|
||||||
|
|
||||||
;; OpenCL vendor ICD configuration
|
;; OpenCL vendor ICD configuration
|
||||||
(substitute* "nvidia.icd"
|
(substitute* "nvidia.icd"
|
||||||
((".*" all) (string-append #$output "/lib/" all)))
|
(("libnvidia-opencl\\.so\\.." all)
|
||||||
|
(string-append #$output "/lib/" all)))
|
||||||
|
|
||||||
|
;; Vulkan ICD & layer configuraiton
|
||||||
|
(substitute* '("nvidia_icd.json"
|
||||||
|
"nvidia_layers.json")
|
||||||
|
(("libGLX_nvidia\\.so\\.." all)
|
||||||
|
(string-append #$output "/lib/" all)))
|
||||||
|
|
||||||
;; Add udev rules for nvidia
|
;; Add udev rules for nvidia
|
||||||
(let ((rules "90-nvidia.rules"))
|
(let ((rules "90-nvidia.rules"))
|
||||||
|
@ -202,9 +204,8 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $
|
||||||
(let* ((ld.so (string-append #$(this-package-input "glibc")
|
(let* ((ld.so (string-append #$(this-package-input "glibc")
|
||||||
#$(glibc-dynamic-linker)))
|
#$(glibc-dynamic-linker)))
|
||||||
(rpath (string-join
|
(rpath (string-join
|
||||||
(list "$ORIGIN"
|
(list (string-append #$output "/lib")
|
||||||
(string-append #$output "/lib")
|
(string-append (ungexp (this-package-input "gcc") "lib") "/lib")
|
||||||
(string-append #$gcc:lib "/lib")
|
|
||||||
(string-append #$(this-package-input "glibc") "/lib")
|
(string-append #$(this-package-input "glibc") "/lib")
|
||||||
(string-append #$(this-package-input "libdrm") "/lib")
|
(string-append #$(this-package-input "libdrm") "/lib")
|
||||||
(string-append #$(this-package-input "libx11") "/lib")
|
(string-append #$(this-package-input "libx11") "/lib")
|
||||||
|
@ -218,16 +219,45 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $
|
||||||
(invoke "patchelf" "--set-interpreter" ld.so file))
|
(invoke "patchelf" "--set-interpreter" ld.so file))
|
||||||
(invoke "patchelf" "--set-rpath" rpath file)
|
(invoke "patchelf" "--set-rpath" rpath file)
|
||||||
(display " done\n"))
|
(display " done\n"))
|
||||||
|
|
||||||
(for-each (lambda (file)
|
(for-each (lambda (file)
|
||||||
(when (elf-file? file)
|
(when (elf-file? file)
|
||||||
(patch-elf file)))
|
(patch-elf file)))
|
||||||
(append (find-files #$output ".*\\.so")
|
(find-files #$output)))))
|
||||||
(find-files (string-append #$output "/bin")))))))
|
(add-before 'patch-elf 'install-commands
|
||||||
(add-before 'patch-elf 'install-nvidia-smi
|
|
||||||
(lambda _
|
(lambda _
|
||||||
(if (string-match "x86_64-linux"
|
(when (string-match
|
||||||
|
"x86_64-linux"
|
||||||
(or #$(%current-target-system) #$(%current-system)))
|
(or #$(%current-target-system) #$(%current-system)))
|
||||||
(install-file "nvidia-smi" (string-append #$output "/bin")))))
|
(for-each
|
||||||
|
(lambda (binary)
|
||||||
|
(let ((bindir (string-append #$output "/bin"))
|
||||||
|
(manual (string-append binary ".1.gz"))
|
||||||
|
(mandir (string-append #$output "/share/man/man1")))
|
||||||
|
(install-file binary bindir)
|
||||||
|
(when (file-exists? manual)
|
||||||
|
(install-file manual mandir))))
|
||||||
|
'("nvidia-smi")))))
|
||||||
|
(add-before 'patch-elf 'relocate-libraries
|
||||||
|
(lambda _
|
||||||
|
(let* ((libdir (string-append #$output "/lib"))
|
||||||
|
(xorgmoddir (string-append libdir "/xorg/modules"))
|
||||||
|
(xorgdrvdir (string-append xorgmoddir "/drivers"))
|
||||||
|
(xorgextdir (string-append xorgmoddir "/extensions"))
|
||||||
|
(move-to-dir (lambda (file dir)
|
||||||
|
(install-file file dir)
|
||||||
|
(delete-file file))))
|
||||||
|
(for-each
|
||||||
|
(cut move-to-dir <> xorgdrvdir)
|
||||||
|
(find-files libdir "nvidia_drv\\.so$"))
|
||||||
|
|
||||||
|
(for-each
|
||||||
|
(lambda (file)
|
||||||
|
(move-to-dir file xorgextdir)
|
||||||
|
(with-directory-excursion xorgextdir
|
||||||
|
(symlink (basename file)
|
||||||
|
"libglxserver_nvidia.so")))
|
||||||
|
(find-files libdir "libglxserver_nvidia\\.so\\.")))))
|
||||||
(add-after 'patch-elf 'create-short-name-symlinks
|
(add-after 'patch-elf 'create-short-name-symlinks
|
||||||
(lambda _
|
(lambda _
|
||||||
(define (get-soname file)
|
(define (get-soname file)
|
||||||
|
@ -237,7 +267,6 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $
|
||||||
(soname (read-line port)))
|
(soname (read-line port)))
|
||||||
(close-pipe port)
|
(close-pipe port)
|
||||||
soname)))
|
soname)))
|
||||||
|
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (lib)
|
(lambda (lib)
|
||||||
(let ((lib-soname (get-soname lib)))
|
(let ((lib-soname (get-soname lib)))
|
||||||
|
@ -257,11 +286,7 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $
|
||||||
(symlink source target)
|
(symlink source target)
|
||||||
(display " done\n")))
|
(display " done\n")))
|
||||||
(list soname base))))))
|
(list soname base))))))
|
||||||
(find-files #$output "\\.so"))
|
(find-files #$output "\\.so\\.")))))))
|
||||||
(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 '("i686-linux" "x86_64-linux"))
|
(supported-systems '("i686-linux" "x86_64-linux"))
|
||||||
(native-inputs (list patchelf))
|
(native-inputs (list patchelf))
|
||||||
(inputs
|
(inputs
|
||||||
|
@ -281,8 +306,7 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $
|
||||||
"This is the evil NVIDIA driver. Don't forget to add @code{service
|
"This is the evil NVIDIA driver. Don't forget to add @code{service
|
||||||
nvidia-service-type} to your @file{config.scm}. Further xorg should be
|
nvidia-service-type} to your @file{config.scm}. Further xorg should be
|
||||||
configured by adding: @code{(modules (cons* nvidia-driver
|
configured by adding: @code{(modules (cons* nvidia-driver
|
||||||
%default-xorg-modules)) (drivers '(\"nvidia\"))} to @code{xorg-configuration}.
|
%default-xorg-modules)) (drivers '(\"nvidia\"))} to @code{xorg-configuration}.")
|
||||||
")
|
|
||||||
(license
|
(license
|
||||||
(license:nonfree
|
(license:nonfree
|
||||||
(format #f "file:///share/doc/nvidia-driver-~a/LICENSE" version)))))
|
(format #f "file:///share/doc/nvidia-driver-~a/LICENSE" version)))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user