From 387d13492fbc7f9e862c558a87255fa436aa0f7a Mon Sep 17 00:00:00 2001 From: Petr Hodina Date: Wed, 8 Jun 2022 06:28:24 +0200 Subject: [PATCH] nongnu: nvidia-driver: Use gexp. * nongnu/packages/nvidia.scm (nvidia-driver): Use gexp. Signed-off-by: Jonathan Brielmaier --- nongnu/packages/nvidia.scm | 89 ++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/nongnu/packages/nvidia.scm b/nongnu/packages/nvidia.scm index 4360d7d..b473427 100644 --- a/nongnu/packages/nvidia.scm +++ b/nongnu/packages/nvidia.scm @@ -78,15 +78,15 @@ (file-name (string-append "nvidia-driver-" version "-checkout")))) (build-system linux-module-build-system) (arguments - `(#:linux ,linux-lts + (list #:linux linux-lts + #:tests? #f #:phases - (modify-phases %standard-phases + #~(modify-phases %standard-phases (replace 'unpack (lambda* (#:key inputs #:allow-other-keys #:rest r) (let ((source (assoc-ref inputs "source"))) (invoke "sh" source "--extract-only") - (chdir ,(format #f "NVIDIA-Linux-x86_64-~a" version)) - #t))) + (chdir #$(format #f "NVIDIA-Linux-x86_64-~a" version))))) (replace 'build (lambda* (#:key inputs outputs #:allow-other-keys) ;; We cannot use with-directory-excursion, because the install @@ -95,15 +95,13 @@ (chdir "kernel") ;; Patch Kbuild (substitute* "Kbuild" - (("/bin/sh") (string-append (assoc-ref inputs "bash-minimal") "/bin/sh"))) + (("/bin/sh") (string-append #$bash-minimal "/bin/sh"))) (invoke "make" "-j" (string-append "SYSSRC=" (assoc-ref inputs "linux-module-builder") "/lib/modules/build") - "CC=gcc") - #t)) - (delete 'check) + "CC=gcc"))) (delete 'strip) (add-after 'install 'install-copy (lambda* (#:key inputs native-inputs outputs #:allow-other-keys) @@ -111,10 +109,9 @@ (use-modules (ice-9 ftw) (ice-9 regex) (ice-9 textual-ports)) - (let* ((out (assoc-ref outputs "out")) - (libdir (string-append out "/lib")) - (bindir (string-append out "/bin")) - (etcdir (string-append out "/etc"))) + (let* ((libdir (string-append #$output "/lib")) + (bindir (string-append #$output "/bin")) + (etcdir (string-append #$output "/etc"))) ;; ------------------------------ ;; Copy .so files (for-each @@ -124,24 +121,26 @@ (scandir "." (lambda (name) (string-contains name ".so")))) - (install-file "nvidia_drv.so" (string-append out "/lib/xorg/modules/drivers/")) - (install-file ,(string-append "libglxserver_nvidia.so." version) (string-append out "/lib/xorg/modules/extensions/")) + (install-file "nvidia_drv.so" (string-append #$output "/lib/xorg/modules/drivers/")) + (install-file (string-append "libglxserver_nvidia.so." + #$(package-version nvidia-driver)) + (string-append #$output "/lib/xorg/modules/extensions/")) ;; 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 out "/lib/libnvidia-opencl.so.1") port))) + (display (string-append #$output "/lib/libnvidia-opencl.so.1") port))) (chmod file #o555)) ;; Add udev rules for nvidia - (let ((rulesdir (string-append out "/lib/udev/rules.d/")) - (rules (string-append out "/lib/udev/rules.d/90-nvidia.rules")) - (sh (string-append (assoc-ref inputs "bash-minimal") "/bin/sh")) - (mknod (string-append (assoc-ref inputs "coreutils") "/bin/mknod")) - (cut (string-append (assoc-ref inputs "coreutils") "/bin/cut")) - (grep (string-append (assoc-ref inputs "grep") "/bin/grep"))) + (let ((rulesdir (string-append #$output "/lib/udev/rules.d/")) + (rules (string-append #$output "/lib/udev/rules.d/90-nvidia.rules")) + (sh (string-append #$bash-minimal "/bin/sh")) + (mknod (string-append #$coreutils "/bin/mknod")) + (cut (string-append #$coreutils "/bin/cut")) + (grep (string-append #$grep "/bin/grep"))) (mkdir-p rulesdir) (call-with-output-file rules (lambda (port) @@ -162,21 +161,20 @@ ;; Add a file to load nvidia drivers (mkdir-p bindir) (let ((file (string-append bindir "/nvidia-insmod")) - (out (assoc-ref outputs "out")) (moddir (string-append "/lib/modules/" (utsname:release (uname)) "-gnu/extra"))) (call-with-output-file file (lambda (port) (put-string port (string-append "#!" (assoc-ref inputs "bash-minimal") "/bin/sh" "\n" "modprobe ipmi_devintf" "\n" - "insmod " out moddir "/nvidia.ko" "\n" - "insmod " out moddir "/nvidia-modeset.ko" "\n" - "insmod " out moddir "/nvidia-uvm.ko" "\n" - "insmod " out moddir "/nvidia-drm.ko" "\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 "#!" (assoc-ref inputs "bash-minimal") "/bin/sh" "\n" + (put-string port (string-append "#!" #$bash-minimal "/bin/sh" "\n" "rmmod " "nvidia-drm" "\n" "rmmod " "nvidia-uvm" "\n" "rmmod " "nvidia-modeset" "\n" @@ -191,24 +189,23 @@ ;; ------------------------------ ;; patchelf - (let* ((libc (assoc-ref inputs "libc")) - (ld.so (string-append libc ,(glibc-dynamic-linker))) + (let* ((ld.so (string-append #$glibc #$(glibc-dynamic-linker))) - (out (assoc-ref outputs "out")) (rpath (string-join (list "$ORIGIN" - (string-append out "/lib") - (string-append libc "/lib") - (string-append (assoc-ref inputs "libx11") "/lib") - (string-append (assoc-ref inputs "libxext") "/lib") - (string-append (assoc-ref inputs "pango") "/lib") - (string-append (assoc-ref inputs "gtk+") "/lib") - (string-append (assoc-ref inputs "gtk2") "/lib") - (string-append (assoc-ref inputs "atk") "/lib") - (string-append (assoc-ref inputs "glib") "/lib") - (string-append (assoc-ref inputs "cairo") "/lib") - (string-append (assoc-ref inputs "gdk-pixbuf") "/lib") - (string-append (assoc-ref inputs "wayland") "/lib") + (string-append #$output "/lib") + (string-append #$glibc "/lib") + (string-append #$libx11 "/lib") + (string-append #$libxext "/lib") + (string-append #$pango "/lib") + (string-append #$gtk+ "/lib") + (string-append #$gtk+-2 "/lib") + (string-append #$atk "/lib") + (string-append #$glib "/lib") + (string-append #$cairo "/lib") + (string-append #$gdk-pixbuf "/lib") + (string-append #$wayland "/lib") + ; TODO: Replace this assoc-ref (string-append (assoc-ref inputs "gcc:lib") "/lib")) ":"))) (define (patch-elf file) @@ -219,7 +216,7 @@ (for-each (lambda (file) (when (elf-file? file) (patch-elf file))) - (find-files out ".*\\.so")) + (find-files #$output ".*\\.so")) (patch-elf (string-append bindir "/" "nvidia-smi"))) ;; ------------------------------ @@ -248,9 +245,9 @@ (format #t "Linking ~a to ~a ...~%" mid file) (symlink (basename file) mid-file)))) (find-files libdir "\\.so\\.")) - (symlink ,(string-append "libglxserver_nvidia.so." version) - (string-append out "/lib/xorg/modules/extensions/" "libglxserver_nvidia.so"))) - #t))))) + (symlink (string-append "libglxserver_nvidia.so." + #$(package-version nvidia-driver)) + (string-append #$output "/lib/xorg/modules/extensions/" "libglxserver_nvidia.so")))))))) (supported-systems '("x86_64-linux")) (native-inputs `(("patchelf" ,patchelf)