mirror of
https://gitlab.com/nonguix/nonguix.git
synced 2024-11-22 08:28:09 +01:00
services: nvidia: Only invoke commands when NVIDIA driver is in use.
* nongnu/services/nvidia.scm (nvidia-service-type): Don't extend kernel-module-loader-service-type, move this part to… (nvidia-shepherd-service)[start]: …here. Check driver and command availablity. [stop]: Likewise. [modules]: Add (guix build utils) for ‘invoke/quiet’. Add (rnrs io ports) for ‘get-line’. Signed-off-by: John Kehayias <john.kehayias@protonmail.com>
This commit is contained in:
parent
97925d2091
commit
8a56ebb666
1 changed files with 10 additions and 5 deletions
|
@ -34,10 +34,17 @@
|
||||||
(provision '(nvidia))
|
(provision '(nvidia))
|
||||||
(requirement '(udev))
|
(requirement '(udev))
|
||||||
(one-shot? #t)
|
(one-shot? #t)
|
||||||
|
(modules '(((guix build utils) #:select (invoke/quiet))
|
||||||
|
((rnrs io ports) #:select (get-line))))
|
||||||
(start
|
(start
|
||||||
#~(lambda _
|
#~(lambda _
|
||||||
(when (file-exists? #$nvidia-smi)
|
(when (file-exists? "/proc/driver/nvidia")
|
||||||
(system* #$nvidia-smi))))))))
|
(let ((modprobe (call-with-input-file
|
||||||
|
"/proc/sys/kernel/modprobe" get-line)))
|
||||||
|
(false-if-exception
|
||||||
|
(begin
|
||||||
|
(invoke/quiet modprobe "--" "nvidia_uvm")
|
||||||
|
(invoke/quiet #$nvidia-smi)))))))))))
|
||||||
|
|
||||||
(define nvidia-service-type
|
(define nvidia-service-type
|
||||||
(service-type
|
(service-type
|
||||||
|
@ -52,8 +59,6 @@
|
||||||
(service-extension firmware-service-type
|
(service-extension firmware-service-type
|
||||||
(compose list nvidia-configuration-firmware))
|
(compose list nvidia-configuration-firmware))
|
||||||
(service-extension linux-loadable-module-service-type
|
(service-extension linux-loadable-module-service-type
|
||||||
(compose list nvidia-configuration-module))
|
(compose list nvidia-configuration-module))))
|
||||||
(service-extension kernel-module-loader-service-type
|
|
||||||
(const '("nvidia_uvm")))))
|
|
||||||
(default-value (nvidia-configuration))
|
(default-value (nvidia-configuration))
|
||||||
(description "Prepare system environment for NVIDIA driver.")))
|
(description "Prepare system environment for NVIDIA driver.")))
|
||||||
|
|
Loading…
Reference in a new issue