2014-04-29 13:16:34 +01:00
|
|
|
|
# This module provides the proprietary NVIDIA X11 / OpenGL drivers.
|
|
|
|
|
|
|
|
|
|
{ config, lib, pkgs, pkgs_i686, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
drivers = config.services.xserver.videoDrivers;
|
|
|
|
|
|
|
|
|
|
# FIXME: should introduce an option like
|
|
|
|
|
# ‘hardware.video.nvidia.package’ for overriding the default NVIDIA
|
|
|
|
|
# driver.
|
2015-02-21 15:29:36 +00:00
|
|
|
|
nvidiaForKernel = kernelPackages:
|
2014-04-29 13:16:34 +01:00
|
|
|
|
if elem "nvidia" drivers then
|
2015-04-04 05:53:34 +01:00
|
|
|
|
kernelPackages.nvidia_x11
|
2016-03-07 22:25:59 +00:00
|
|
|
|
else if elem "nvidiaBeta" drivers then
|
|
|
|
|
kernelPackages.nvidia_x11_beta
|
2014-05-13 17:35:57 +01:00
|
|
|
|
else if elem "nvidiaLegacy304" drivers then
|
2015-02-21 15:29:36 +00:00
|
|
|
|
kernelPackages.nvidia_x11_legacy304
|
2014-11-24 21:34:00 +00:00
|
|
|
|
else if elem "nvidiaLegacy340" drivers then
|
2015-02-21 15:29:36 +00:00
|
|
|
|
kernelPackages.nvidia_x11_legacy340
|
|
|
|
|
else null;
|
|
|
|
|
|
|
|
|
|
nvidia_x11 = nvidiaForKernel config.boot.kernelPackages;
|
|
|
|
|
nvidia_libs32 = (nvidiaForKernel pkgs_i686.linuxPackages).override { libsOnly = true; kernel = null; };
|
2014-04-29 13:16:34 +01:00
|
|
|
|
|
2015-02-21 15:29:36 +00:00
|
|
|
|
enabled = nvidia_x11 != null;
|
2014-04-29 13:16:34 +01:00
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
config = mkIf enabled {
|
2017-05-07 21:27:02 +01:00
|
|
|
|
assertions = [
|
|
|
|
|
{
|
2017-09-28 21:11:16 +01:00
|
|
|
|
assertion = config.services.xserver.displayManager.gdm.wayland;
|
2017-05-07 21:27:02 +01:00
|
|
|
|
message = "NVidia drivers don't support wayland";
|
|
|
|
|
}
|
|
|
|
|
];
|
2014-04-29 13:16:34 +01:00
|
|
|
|
|
|
|
|
|
services.xserver.drivers = singleton
|
2017-01-29 21:29:39 +00:00
|
|
|
|
{ name = "nvidia"; modules = [ nvidia_x11.bin ]; libPath = [ nvidia_x11 ]; };
|
2014-04-29 13:16:34 +01:00
|
|
|
|
|
|
|
|
|
services.xserver.screenSection =
|
|
|
|
|
''
|
|
|
|
|
Option "RandRRotation" "on"
|
|
|
|
|
'';
|
|
|
|
|
|
2017-02-11 14:11:18 +00:00
|
|
|
|
environment.etc."nvidia/nvidia-application-profiles-rc" = mkIf nvidia_x11.useProfiles {
|
|
|
|
|
source = "${nvidia_x11.bin}/share/nvidia/nvidia-application-profiles-rc";
|
|
|
|
|
};
|
|
|
|
|
|
2018-03-17 15:52:42 +00:00
|
|
|
|
hardware.opengl.package = nvidia_x11.out;
|
|
|
|
|
hardware.opengl.package32 = nvidia_libs32.out;
|
2014-04-29 13:16:34 +01:00
|
|
|
|
|
2017-05-30 19:56:34 +01:00
|
|
|
|
environment.systemPackages = [ nvidia_x11.bin nvidia_x11.settings ]
|
|
|
|
|
++ lib.filter (p: p != null) [ nvidia_x11.persistenced ];
|
2014-04-29 13:16:34 +01:00
|
|
|
|
|
2017-01-29 21:29:39 +00:00
|
|
|
|
boot.extraModulePackages = [ nvidia_x11.bin ];
|
2014-04-29 13:16:34 +01:00
|
|
|
|
|
2015-03-03 19:15:38 +00:00
|
|
|
|
# nvidia-uvm is required by CUDA applications.
|
2017-05-07 20:37:56 +01:00
|
|
|
|
boot.kernelModules = [ "nvidia-uvm" ] ++
|
|
|
|
|
lib.optionals config.services.xserver.enable [ "nvidia" "nvidia_modeset" "nvidia_drm" ];
|
|
|
|
|
|
2015-03-03 19:15:38 +00:00
|
|
|
|
|
|
|
|
|
# Create /dev/nvidia-uvm when the nvidia-uvm module is loaded.
|
|
|
|
|
services.udev.extraRules =
|
|
|
|
|
''
|
2018-03-01 19:38:53 +00:00
|
|
|
|
KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c $(grep nvidia-frontend /proc/devices | cut -d \ -f 1) 255'"
|
|
|
|
|
KERNEL=="nvidia_modeset", RUN+="${pkgs.runtimeShell} -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.runtimeShell} -c 'mknod -m 666 /dev/nvidia%n c $(grep nvidia-frontend /proc/devices | cut -d \ -f 1) %n'"
|
|
|
|
|
KERNEL=="nvidia_uvm", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-uvm c $(grep nvidia-uvm /proc/devices | cut -d \ -f 1) 0'"
|
2015-03-03 19:15:38 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2014-04-29 13:16:34 +01:00
|
|
|
|
boot.blacklistedKernelModules = [ "nouveau" "nvidiafb" ];
|
|
|
|
|
|
|
|
|
|
services.acpid.enable = true;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|