nongnu: nvidia-driver: Simplify udev rules creation.

* nongnu/packages/nvidia.scm (nvidia-driver)[arguments]<#:phases>: Simplify udev rules creation.

Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
This commit is contained in:
Hilton Chain 2022-11-20 22:11:18 +08:00 committed by Jonathan Brielmaier
parent 9f4e8e82f1
commit fe9813a3ee
No known key found for this signature in database
GPG key ID: ECFC83988B4E4B9F

View file

@ -135,26 +135,20 @@
;; Add udev rules for nvidia ;; Add udev rules for nvidia
(let ((rulesdir (string-append #$output "/lib/udev/rules.d/")) (let ((rulesdir (string-append #$output "/lib/udev/rules.d/"))
(rules (string-append #$output "/lib/udev/rules.d/90-nvidia.rules")) (rules (string-append #$output "/lib/udev/rules.d/90-nvidia.rules")))
(sh (search-input-file inputs "/bin/sh"))
(mknod (search-input-file inputs "/bin/mknod"))
(cut (search-input-file inputs "/bin/cut"))
(grep (search-input-file inputs "/bin/grep")))
(mkdir-p rulesdir) (mkdir-p rulesdir)
(call-with-output-file rules (call-with-output-file rules
(lambda (port) (lambda (port)
(put-string port (put-string port (format #f "~
(string-append KERNEL==\"nvidia\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidiactl c $$(@grep@ nvidia-frontend /proc/devices | @cut@ -d \\ -f 1) 255'\"
"KERNEL==\"nvidia\", " KERNEL==\"nvidia_modeset\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-modeset c $$(@grep@ nvidia-frontend /proc/devices | @cut@ -d \\ -f 1) 254'\"
"RUN+=\"" sh " -c '" mknod " -m 666 /dev/nvidiactl c $$(" grep " nvidia-frontend /proc/devices | " cut " -d \\ -f 1) 255'\"" "\n" KERNEL==\"card*\", SUBSYSTEM==\"drm\", DRIVERS==\"nvidia\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia0 c $$(@grep@ nvidia-frontend /proc/devices | @cut@ -d \\ -f 1) 0'\"
"KERNEL==\"nvidia_modeset\", " KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm c $$(@grep@ nvidia-uvm /proc/devices | @cut@ -d \\ -f 1) 0'\"
"RUN+=\"" sh " -c '" mknod " -m 666 /dev/nvidia-modeset c $$(" grep " nvidia-frontend /proc/devices | " cut " -d \\ -f 1) 254'\"" "\n" KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $$(@grep@ nvidia-uvm /proc/devices | @cut@ -d \\ -f 1) 0'\"
"KERNEL==\"card*\", SUBSYSTEM==\"drm\", DRIVERS==\"nvidia\", " "))))
"RUN+=\"" sh " -c '" mknod " -m 666 /dev/nvidia0 c $$(" grep " nvidia-frontend /proc/devices | " cut " -d \\ -f 1) 0'\"" "\n" (substitute* rules
"KERNEL==\"nvidia_uvm\", " (("@\\<(sh|grep|mknod|cut)\\>@" all cmd)
"RUN+=\"" sh " -c '" mknod " -m 666 /dev/nvidia-uvm c $$(" grep " nvidia-uvm /proc/devices | " cut " -d \\ -f 1) 0'\"" "\n" (search-input-file inputs (string-append "/bin/" cmd)))))
"KERNEL==\"nvidia_uvm\", "
"RUN+=\"" sh " -c '" mknod " -m 666 /dev/nvidia-uvm-tools c $$(" grep " nvidia-uvm /proc/devices | " cut " -d \\ -f 1) 0'\"" "\n" )))))
;; ------------------------------ ;; ------------------------------
;; Add a file to load nvidia drivers ;; Add a file to load nvidia drivers