From 4f91397c987739cc96e1dd418f79fc0d94326485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rostislav=20Bene=C5=A1?= Date: Sun, 7 May 2017 21:37:56 +0200 Subject: [PATCH] nixos/nvidia: populating /dev with nvidia devices at boot --- nixos/modules/hardware/video/nvidia.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nixos/modules/hardware/video/nvidia.nix b/nixos/modules/hardware/video/nvidia.nix index 80abec95c03d..2bad50d65e7a 100644 --- a/nixos/modules/hardware/video/nvidia.nix +++ b/nixos/modules/hardware/video/nvidia.nix @@ -62,11 +62,16 @@ in boot.extraModulePackages = [ nvidia_x11.bin ]; # nvidia-uvm is required by CUDA applications. - boot.kernelModules = [ "nvidia-uvm" ]; + boot.kernelModules = [ "nvidia-uvm" ] ++ + lib.optionals config.services.xserver.enable [ "nvidia" "nvidia_modeset" "nvidia_drm" ]; + # Create /dev/nvidia-uvm when the nvidia-uvm module is loaded. services.udev.extraRules = '' + KERNEL=="nvidia", RUN+="${pkgs.stdenv.shell} -c 'mknod -m 666 /dev/nvidiactl c $(grep nvidia-frontend /proc/devices | cut -d \ -f 1) 255'" + KERNEL=="nvidia_modeset", RUN+="${pkgs.stdenv.shell} -c 'mknod -m 666 /dev/nvidia-modeset c $(grep nvidia-frontend /proc/devices | cut -d \ -f 1) 254'" + KERNEL=="card*", SUBSYSTEM=="drm", DRIVERS=="nvidia", RUN+="${pkgs.stdenv.shell} -c 'mknod -m 666 /dev/nvidia%n c $(grep nvidia-frontend /proc/devices | cut -d \ -f 1) %n'" KERNEL=="nvidia_uvm", RUN+="${pkgs.stdenv.shell} -c 'mknod -m 666 /dev/nvidia-uvm c $(grep nvidia-uvm /proc/devices | cut -d \ -f 1) 0'" '';