mirror of
https://gitlab.com/nonguix/nonguix.git
synced 2024-11-28 19:24:11 +01:00
nongnu: nvidia-driver: Use copy-build-system.
* nongnu/packages/nvidia.scm (nvidia-driver)[build-system]: Change to copy-build-system. [arguments]<#:phases>: Add create-misc-files phase. Remove build phase. Rename install-copy phase to post-install. Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
This commit is contained in:
parent
53f1b621d9
commit
61c61bd8c2
1 changed files with 40 additions and 81 deletions
|
@ -118,63 +118,47 @@
|
||||||
(name "nvidia-driver")
|
(name "nvidia-driver")
|
||||||
(version nvidia-version)
|
(version nvidia-version)
|
||||||
(source nvidia-source)
|
(source nvidia-source)
|
||||||
(build-system linux-module-build-system)
|
(build-system copy-build-system)
|
||||||
(arguments
|
(arguments
|
||||||
(list #:linux linux-lts
|
(list #:modules '((guix build copy-build-system)
|
||||||
#:tests? #f
|
|
||||||
#:modules '((guix build linux-module-build-system)
|
|
||||||
(guix build utils)
|
(guix build utils)
|
||||||
(ice-9 ftw)
|
(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))
|
||||||
|
#:install-plan
|
||||||
|
#~`(("." "lib/" #:include-regexp ("^./[^/]+\\.so") #:exclude-regexp ("nvidia_drv\\.so" "libglxserver_nvidia\\.so\\..*"))
|
||||||
|
("." "share/nvidia/" #:include-regexp ("nvidia-application-profiles.*"))
|
||||||
|
("10_nvidia_wayland.json" "share/egl/egl_external_platform.d/")
|
||||||
|
("90-nvidia.rules" "lib/udev/rules.d/")
|
||||||
|
("nvidia-drm-outputclass.conf" "share/x11/xorg.conf.d/")
|
||||||
|
("nvidia-smi" "bin/")
|
||||||
|
("nvidia-smi.1.gz" "share/man/man1/")
|
||||||
|
("nvidia.icd" "etc/OpenCL/vendors/")
|
||||||
|
("nvidia_drv.so" "lib/xorg/modules/drivers/")
|
||||||
|
("nvidia_icd.json" "share/vulkan/icd.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
|
||||||
(replace 'build
|
|
||||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
|
||||||
;; We cannot use with-directory-excursion, because the install
|
|
||||||
;; phase needs to be in the kernel folder. Otherwise no .ko
|
|
||||||
;; would be installed.
|
|
||||||
(chdir "kernel")
|
|
||||||
;; Patch Kbuild
|
|
||||||
(substitute* "Kbuild" (("/bin/sh") (which "sh")))
|
|
||||||
(invoke "make" "-j"
|
|
||||||
(string-append "CC=" #$(cc-for-target))
|
|
||||||
(string-append "SYSSRC=" (search-input-directory
|
|
||||||
inputs "/lib/modules/build")))))
|
|
||||||
(delete 'strip)
|
(delete 'strip)
|
||||||
(add-after 'install 'install-copy
|
(add-after 'unpack 'create-misc-files
|
||||||
(lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
|
(lambda* (#:key inputs #:allow-other-keys)
|
||||||
(chdir "..")
|
;; Vulkan layer configuration
|
||||||
(let* ((libdir (string-append #$output "/lib"))
|
(for-each (lambda (file)
|
||||||
(bindir (string-append #$output "/bin"))
|
(substitute* file
|
||||||
(etcdir (string-append #$output "/etc")))
|
(("lib(GLX|nvidia).*\\.so\\..*" all)
|
||||||
;; ------------------------------
|
(string-append #$output "/lib/" all))))
|
||||||
;; Copy .so files
|
|
||||||
(for-each
|
|
||||||
(lambda (file)
|
|
||||||
(format #t "Copying '~a'...~%" file)
|
|
||||||
(install-file file libdir))
|
|
||||||
(scandir "." (lambda (name)
|
(scandir "." (lambda (name)
|
||||||
(string-contains name ".so"))))
|
(string-contains name ".json"))))
|
||||||
|
|
||||||
(install-file "nvidia_drv.so" (string-append #$output "/lib/xorg/modules/drivers/"))
|
;; OpenCL vendor ICD configuration
|
||||||
(install-file (string-append "libglxserver_nvidia.so." #$version)
|
(substitute* "nvidia.icd"
|
||||||
(string-append #$output "/lib/xorg/modules/extensions/"))
|
((".*" all) (string-append #$output "/lib/" all)))
|
||||||
|
|
||||||
;; ICD Loader for OpenCL
|
|
||||||
(let ((file (string-append etcdir "/OpenCL/vendors/nvidia.icd")))
|
|
||||||
(mkdir-p (string-append etcdir "/OpenCL/vendors/"))
|
|
||||||
(call-with-output-file file
|
|
||||||
(lambda (port)
|
|
||||||
(display (string-append #$output "/lib/libnvidia-opencl.so.1") port)))
|
|
||||||
(chmod file #o555))
|
|
||||||
|
|
||||||
;; Add udev rules for nvidia
|
;; Add udev rules for nvidia
|
||||||
(let ((rulesdir (string-append #$output "/lib/udev/rules.d/"))
|
(let ((rules "90-nvidia.rules"))
|
||||||
(rules (string-append #$output "/lib/udev/rules.d/90-nvidia.rules")))
|
|
||||||
(mkdir-p rulesdir)
|
|
||||||
(call-with-output-file rules
|
(call-with-output-file rules
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(put-string port (format #f "~
|
(put-string port (format #f "~
|
||||||
|
@ -186,37 +170,12 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $
|
||||||
"))))
|
"))))
|
||||||
(substitute* rules
|
(substitute* rules
|
||||||
(("@\\<(sh|grep|mknod|cut)\\>@" all cmd)
|
(("@\\<(sh|grep|mknod|cut)\\>@" all cmd)
|
||||||
(search-input-file inputs (string-append "/bin/" cmd)))))
|
(search-input-file inputs (string-append "/bin/" cmd)))))))
|
||||||
|
(add-after 'install 'post-install
|
||||||
;; ------------------------------
|
(lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
|
||||||
;; Add a file to load nvidia drivers
|
(let* ((libdir (string-append #$output "/lib"))
|
||||||
(mkdir-p bindir)
|
(bindir (string-append #$output "/bin"))
|
||||||
(let ((file (string-append bindir "/nvidia-insmod"))
|
(etcdir (string-append #$output "/etc")))
|
||||||
(moddir (string-append "/lib/modules/" (utsname:release (uname)) "-gnu/extra")))
|
|
||||||
(call-with-output-file file
|
|
||||||
(lambda (port)
|
|
||||||
(put-string port (string-append "#!" (search-input-file inputs "/bin/sh") "\n"
|
|
||||||
"modprobe ipmi_devintf" "\n"
|
|
||||||
"insmod " #$output moddir "/nvidia.ko" "\n"
|
|
||||||
"insmod " #$output moddir "/nvidia-modeset.ko" "\n"
|
|
||||||
"insmod " #$output moddir "/nvidia-uvm.ko" "\n"
|
|
||||||
"insmod " #$output moddir "/nvidia-drm.ko" "\n"))))
|
|
||||||
(chmod file #o555))
|
|
||||||
(let ((file (string-append bindir "/nvidia-rmmod")))
|
|
||||||
(call-with-output-file file
|
|
||||||
(lambda (port)
|
|
||||||
(put-string port (string-append "#!" (search-input-file inputs "/bin/sh") "\n"
|
|
||||||
"rmmod " "nvidia-drm" "\n"
|
|
||||||
"rmmod " "nvidia-uvm" "\n"
|
|
||||||
"rmmod " "nvidia-modeset" "\n"
|
|
||||||
"rmmod " "nvidia" "\n"
|
|
||||||
"rmmod " "ipmi_devintf" "\n"))))
|
|
||||||
(chmod file #o555))
|
|
||||||
|
|
||||||
;; ------------------------------
|
|
||||||
;; nvidia-smi
|
|
||||||
|
|
||||||
(install-file "nvidia-smi" bindir)
|
|
||||||
|
|
||||||
;; ------------------------------
|
;; ------------------------------
|
||||||
;; patchelf
|
;; patchelf
|
||||||
|
|
Loading…
Reference in a new issue