services: nvidia: Create extra device nodes on boot.

* nongnu/services/nvidia.scm (nvidia-shepherd-service)
[requirement]: Add udev.
[start]: Create extra device nodes via ‘nvidia-smi’.

Signed-off-by: John Kehayias <john.kehayias@protonmail.com>
This commit is contained in:
Hilton Chain 2024-01-07 21:24:14 +08:00 committed by John Kehayias
parent e3896f51d2
commit e4e34b7da4
No known key found for this signature in database
GPG key ID: 499097AE5EA815D9

View file

@ -1,5 +1,5 @@
;;; SPDX-License-Identifier: GPL-3.0-or-later ;;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Copyright © 2022 Hilton Chain <hako@ultrarare.space> ;;; Copyright © 2022, 2024 Hilton Chain <hako@ultrarare.space>
(define-module (nongnu services nvidia) (define-module (nongnu services nvidia)
#:use-module (guix gexp) #:use-module (guix gexp)
@ -27,14 +27,20 @@
(default nvidia-module))) ; file-like (default nvidia-module))) ; file-like
(define (nvidia-shepherd-service config) (define (nvidia-shepherd-service config)
(list (shepherd-service (let ((nvidia-driver (nvidia-configuration-driver config))
(documentation "Prepare system environment for NVIDIA driver.") (nvidia-smi (file-append nvidia-driver "/bin/nvidia-smi"))
(provision '(nvidia)) (rmmod (file-append kmod "/bin/rmmod")))
(requirement '(user-processes)) (list (shepherd-service
(start #~(const #t)) (documentation "Prepare system environment for NVIDIA driver.")
(stop #~(lambda _ (provision '(nvidia))
(let ((rmmod #$(file-append kmod "/bin/rmmod"))) (requirement '(udev user-processes))
(system* rmmod "nvidia_uvm"))))))) (start
#~(lambda _
(when (file-exists? #$nvidia-smi)
(system* #$nvidia-smi))))
(stop
#~(lambda _
(system* #$rmmod "nvidia_uvm")))))))
(define nvidia-service-type (define nvidia-service-type
(service-type (service-type