nongnu: make-nvidia-source: Extend functionality.

* nongnu/packages/nvidia.scm (nvidia-source-unbundle-libraries): New procedure.
(make-nvidia-source): Create installer origin internally.
Accept a ‘get-cleanup-snippet’ procedure.
(nvidia-source): Adjust accordingly.

Signed-off-by: John Kehayias <john.kehayias@protonmail.com>
This commit is contained in:
Hilton Chain 2024-02-01 20:46:05 +08:00 committed by John Kehayias
parent 5f7dabe418
commit 4bc11de5dd
No known key found for this signature in database
GPG key ID: 499097AE5EA815D9

View file

@ -72,12 +72,27 @@
;;; ;;;
;; Extract the driver installer and make it a new origin instance for reusing. (define (nvidia-source-unbundle-libraries version)
(define (make-nvidia-source version installer) #t)
(define* (make-nvidia-source
version hash
#:optional (get-cleanup-snippet nvidia-source-unbundle-libraries))
"Given VERSION and HASH of an NVIDIA driver installer, return an <origin> for
its unpacked checkout. GET-CLEANUP-SNIPPET is a procedure that accepts the
VERSION as argument and returns a G-expression."
(define installer
(origin
(method url-fetch)
(uri (string-append
"https://us.download.nvidia.com/XFree86/Linux-x86_64/"
version "/NVIDIA-Linux-x86_64-" version ".run"))
(sha256 hash)))
(origin (origin
(method (@@ (guix packages) computed-origin-method)) (method (@@ (guix packages) computed-origin-method))
(file-name (string-append "nvidia-driver-" version "-checkout")) (file-name (string-append "nvidia-driver-" version "-checkout"))
(sha256 #f) (sha256 #f)
(snippet (get-cleanup-snippet version))
(uri (uri
(delay (delay
(with-imported-modules '((guix build utils)) (with-imported-modules '((guix build utils))
@ -102,16 +117,9 @@
#$output))))))) #$output)))))))
(define-public nvidia-source (define-public nvidia-source
(let ((version nvidia-version))
(make-nvidia-source (make-nvidia-source
version nvidia-version
(origin (base32 "0i5zyvlsjnfkpfqhw6pklp0ws8nndyiwxrg4pj04jpwnxf6a38n6")))
(method url-fetch)
(uri (string-append
"https://us.download.nvidia.com/XFree86/Linux-x86_64/"
version "/NVIDIA-Linux-x86_64-" version ".run"))
(sha256
(base32 "0i5zyvlsjnfkpfqhw6pklp0ws8nndyiwxrg4pj04jpwnxf6a38n6"))))))
;;; ;;;