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