mirror of
https://gitlab.com/nonguix/nonguix.git
synced 2024-11-28 19:24:11 +01:00
nongnu: nvidia-driver: Use gexp.
* nongnu/packages/nvidia.scm (nvidia-driver): Use gexp. Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
This commit is contained in:
parent
32c687865d
commit
387d13492f
1 changed files with 43 additions and 46 deletions
|
@ -78,15 +78,15 @@
|
||||||
(file-name (string-append "nvidia-driver-" version "-checkout"))))
|
(file-name (string-append "nvidia-driver-" version "-checkout"))))
|
||||||
(build-system linux-module-build-system)
|
(build-system linux-module-build-system)
|
||||||
(arguments
|
(arguments
|
||||||
`(#:linux ,linux-lts
|
(list #:linux linux-lts
|
||||||
|
#:tests? #f
|
||||||
#:phases
|
#:phases
|
||||||
(modify-phases %standard-phases
|
#~(modify-phases %standard-phases
|
||||||
(replace 'unpack
|
(replace 'unpack
|
||||||
(lambda* (#:key inputs #:allow-other-keys #:rest r)
|
(lambda* (#:key inputs #:allow-other-keys #:rest r)
|
||||||
(let ((source (assoc-ref inputs "source")))
|
(let ((source (assoc-ref inputs "source")))
|
||||||
(invoke "sh" source "--extract-only")
|
(invoke "sh" source "--extract-only")
|
||||||
(chdir ,(format #f "NVIDIA-Linux-x86_64-~a" version))
|
(chdir #$(format #f "NVIDIA-Linux-x86_64-~a" version)))))
|
||||||
#t)))
|
|
||||||
(replace 'build
|
(replace 'build
|
||||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||||
;; We cannot use with-directory-excursion, because the install
|
;; We cannot use with-directory-excursion, because the install
|
||||||
|
@ -95,15 +95,13 @@
|
||||||
(chdir "kernel")
|
(chdir "kernel")
|
||||||
;; Patch Kbuild
|
;; Patch Kbuild
|
||||||
(substitute* "Kbuild"
|
(substitute* "Kbuild"
|
||||||
(("/bin/sh") (string-append (assoc-ref inputs "bash-minimal") "/bin/sh")))
|
(("/bin/sh") (string-append #$bash-minimal "/bin/sh")))
|
||||||
(invoke "make"
|
(invoke "make"
|
||||||
"-j"
|
"-j"
|
||||||
(string-append "SYSSRC="
|
(string-append "SYSSRC="
|
||||||
(assoc-ref inputs "linux-module-builder")
|
(assoc-ref inputs "linux-module-builder")
|
||||||
"/lib/modules/build")
|
"/lib/modules/build")
|
||||||
"CC=gcc")
|
"CC=gcc")))
|
||||||
#t))
|
|
||||||
(delete 'check)
|
|
||||||
(delete 'strip)
|
(delete 'strip)
|
||||||
(add-after 'install 'install-copy
|
(add-after 'install 'install-copy
|
||||||
(lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
|
(lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
|
||||||
|
@ -111,10 +109,9 @@
|
||||||
(use-modules (ice-9 ftw)
|
(use-modules (ice-9 ftw)
|
||||||
(ice-9 regex)
|
(ice-9 regex)
|
||||||
(ice-9 textual-ports))
|
(ice-9 textual-ports))
|
||||||
(let* ((out (assoc-ref outputs "out"))
|
(let* ((libdir (string-append #$output "/lib"))
|
||||||
(libdir (string-append out "/lib"))
|
(bindir (string-append #$output "/bin"))
|
||||||
(bindir (string-append out "/bin"))
|
(etcdir (string-append #$output "/etc")))
|
||||||
(etcdir (string-append out "/etc")))
|
|
||||||
;; ------------------------------
|
;; ------------------------------
|
||||||
;; Copy .so files
|
;; Copy .so files
|
||||||
(for-each
|
(for-each
|
||||||
|
@ -124,24 +121,26 @@
|
||||||
(scandir "." (lambda (name)
|
(scandir "." (lambda (name)
|
||||||
(string-contains name ".so"))))
|
(string-contains name ".so"))))
|
||||||
|
|
||||||
(install-file "nvidia_drv.so" (string-append out "/lib/xorg/modules/drivers/"))
|
(install-file "nvidia_drv.so" (string-append #$output "/lib/xorg/modules/drivers/"))
|
||||||
(install-file ,(string-append "libglxserver_nvidia.so." version) (string-append out "/lib/xorg/modules/extensions/"))
|
(install-file (string-append "libglxserver_nvidia.so."
|
||||||
|
#$(package-version nvidia-driver))
|
||||||
|
(string-append #$output "/lib/xorg/modules/extensions/"))
|
||||||
|
|
||||||
;; ICD Loader for OpenCL
|
;; ICD Loader for OpenCL
|
||||||
(let ((file (string-append etcdir "/OpenCL/vendors/nvidia.icd")))
|
(let ((file (string-append etcdir "/OpenCL/vendors/nvidia.icd")))
|
||||||
(mkdir-p (string-append etcdir "/OpenCL/vendors/"))
|
(mkdir-p (string-append etcdir "/OpenCL/vendors/"))
|
||||||
(call-with-output-file file
|
(call-with-output-file file
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(display (string-append out "/lib/libnvidia-opencl.so.1") port)))
|
(display (string-append #$output "/lib/libnvidia-opencl.so.1") port)))
|
||||||
(chmod file #o555))
|
(chmod file #o555))
|
||||||
|
|
||||||
;; Add udev rules for nvidia
|
;; Add udev rules for nvidia
|
||||||
(let ((rulesdir (string-append out "/lib/udev/rules.d/"))
|
(let ((rulesdir (string-append #$output "/lib/udev/rules.d/"))
|
||||||
(rules (string-append out "/lib/udev/rules.d/90-nvidia.rules"))
|
(rules (string-append #$output "/lib/udev/rules.d/90-nvidia.rules"))
|
||||||
(sh (string-append (assoc-ref inputs "bash-minimal") "/bin/sh"))
|
(sh (string-append #$bash-minimal "/bin/sh"))
|
||||||
(mknod (string-append (assoc-ref inputs "coreutils") "/bin/mknod"))
|
(mknod (string-append #$coreutils "/bin/mknod"))
|
||||||
(cut (string-append (assoc-ref inputs "coreutils") "/bin/cut"))
|
(cut (string-append #$coreutils "/bin/cut"))
|
||||||
(grep (string-append (assoc-ref inputs "grep") "/bin/grep")))
|
(grep (string-append #$grep "/bin/grep")))
|
||||||
(mkdir-p rulesdir)
|
(mkdir-p rulesdir)
|
||||||
(call-with-output-file rules
|
(call-with-output-file rules
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
|
@ -162,21 +161,20 @@
|
||||||
;; Add a file to load nvidia drivers
|
;; Add a file to load nvidia drivers
|
||||||
(mkdir-p bindir)
|
(mkdir-p bindir)
|
||||||
(let ((file (string-append bindir "/nvidia-insmod"))
|
(let ((file (string-append bindir "/nvidia-insmod"))
|
||||||
(out (assoc-ref outputs "out"))
|
|
||||||
(moddir (string-append "/lib/modules/" (utsname:release (uname)) "-gnu/extra")))
|
(moddir (string-append "/lib/modules/" (utsname:release (uname)) "-gnu/extra")))
|
||||||
(call-with-output-file file
|
(call-with-output-file file
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(put-string port (string-append "#!" (assoc-ref inputs "bash-minimal") "/bin/sh" "\n"
|
(put-string port (string-append "#!" (assoc-ref inputs "bash-minimal") "/bin/sh" "\n"
|
||||||
"modprobe ipmi_devintf" "\n"
|
"modprobe ipmi_devintf" "\n"
|
||||||
"insmod " out moddir "/nvidia.ko" "\n"
|
"insmod " #$output moddir "/nvidia.ko" "\n"
|
||||||
"insmod " out moddir "/nvidia-modeset.ko" "\n"
|
"insmod " #$output moddir "/nvidia-modeset.ko" "\n"
|
||||||
"insmod " out moddir "/nvidia-uvm.ko" "\n"
|
"insmod " #$output moddir "/nvidia-uvm.ko" "\n"
|
||||||
"insmod " out moddir "/nvidia-drm.ko" "\n"))))
|
"insmod " #$output moddir "/nvidia-drm.ko" "\n"))))
|
||||||
(chmod file #o555))
|
(chmod file #o555))
|
||||||
(let ((file (string-append bindir "/nvidia-rmmod")))
|
(let ((file (string-append bindir "/nvidia-rmmod")))
|
||||||
(call-with-output-file file
|
(call-with-output-file file
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(put-string port (string-append "#!" (assoc-ref inputs "bash-minimal") "/bin/sh" "\n"
|
(put-string port (string-append "#!" #$bash-minimal "/bin/sh" "\n"
|
||||||
"rmmod " "nvidia-drm" "\n"
|
"rmmod " "nvidia-drm" "\n"
|
||||||
"rmmod " "nvidia-uvm" "\n"
|
"rmmod " "nvidia-uvm" "\n"
|
||||||
"rmmod " "nvidia-modeset" "\n"
|
"rmmod " "nvidia-modeset" "\n"
|
||||||
|
@ -191,24 +189,23 @@
|
||||||
|
|
||||||
;; ------------------------------
|
;; ------------------------------
|
||||||
;; patchelf
|
;; patchelf
|
||||||
(let* ((libc (assoc-ref inputs "libc"))
|
(let* ((ld.so (string-append #$glibc #$(glibc-dynamic-linker)))
|
||||||
(ld.so (string-append libc ,(glibc-dynamic-linker)))
|
|
||||||
|
|
||||||
(out (assoc-ref outputs "out"))
|
|
||||||
(rpath (string-join
|
(rpath (string-join
|
||||||
(list "$ORIGIN"
|
(list "$ORIGIN"
|
||||||
(string-append out "/lib")
|
(string-append #$output "/lib")
|
||||||
(string-append libc "/lib")
|
(string-append #$glibc "/lib")
|
||||||
(string-append (assoc-ref inputs "libx11") "/lib")
|
(string-append #$libx11 "/lib")
|
||||||
(string-append (assoc-ref inputs "libxext") "/lib")
|
(string-append #$libxext "/lib")
|
||||||
(string-append (assoc-ref inputs "pango") "/lib")
|
(string-append #$pango "/lib")
|
||||||
(string-append (assoc-ref inputs "gtk+") "/lib")
|
(string-append #$gtk+ "/lib")
|
||||||
(string-append (assoc-ref inputs "gtk2") "/lib")
|
(string-append #$gtk+-2 "/lib")
|
||||||
(string-append (assoc-ref inputs "atk") "/lib")
|
(string-append #$atk "/lib")
|
||||||
(string-append (assoc-ref inputs "glib") "/lib")
|
(string-append #$glib "/lib")
|
||||||
(string-append (assoc-ref inputs "cairo") "/lib")
|
(string-append #$cairo "/lib")
|
||||||
(string-append (assoc-ref inputs "gdk-pixbuf") "/lib")
|
(string-append #$gdk-pixbuf "/lib")
|
||||||
(string-append (assoc-ref inputs "wayland") "/lib")
|
(string-append #$wayland "/lib")
|
||||||
|
; TODO: Replace this assoc-ref
|
||||||
(string-append (assoc-ref inputs "gcc:lib") "/lib"))
|
(string-append (assoc-ref inputs "gcc:lib") "/lib"))
|
||||||
":")))
|
":")))
|
||||||
(define (patch-elf file)
|
(define (patch-elf file)
|
||||||
|
@ -219,7 +216,7 @@
|
||||||
(for-each (lambda (file)
|
(for-each (lambda (file)
|
||||||
(when (elf-file? file)
|
(when (elf-file? file)
|
||||||
(patch-elf file)))
|
(patch-elf file)))
|
||||||
(find-files out ".*\\.so"))
|
(find-files #$output ".*\\.so"))
|
||||||
(patch-elf (string-append bindir "/" "nvidia-smi")))
|
(patch-elf (string-append bindir "/" "nvidia-smi")))
|
||||||
|
|
||||||
;; ------------------------------
|
;; ------------------------------
|
||||||
|
@ -248,9 +245,9 @@
|
||||||
(format #t "Linking ~a to ~a ...~%" mid file)
|
(format #t "Linking ~a to ~a ...~%" mid file)
|
||||||
(symlink (basename file) mid-file))))
|
(symlink (basename file) mid-file))))
|
||||||
(find-files libdir "\\.so\\."))
|
(find-files libdir "\\.so\\."))
|
||||||
(symlink ,(string-append "libglxserver_nvidia.so." version)
|
(symlink (string-append "libglxserver_nvidia.so."
|
||||||
(string-append out "/lib/xorg/modules/extensions/" "libglxserver_nvidia.so")))
|
#$(package-version nvidia-driver))
|
||||||
#t)))))
|
(string-append #$output "/lib/xorg/modules/extensions/" "libglxserver_nvidia.so"))))))))
|
||||||
(supported-systems '("x86_64-linux"))
|
(supported-systems '("x86_64-linux"))
|
||||||
(native-inputs
|
(native-inputs
|
||||||
`(("patchelf" ,patchelf)
|
`(("patchelf" ,patchelf)
|
||||||
|
|
Loading…
Reference in a new issue