2014-04-29 14:16:34 +02: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 16:29:36 +01:00
|
|
|
|
nvidiaForKernel = kernelPackages:
|
2014-04-29 14:16:34 +02:00
|
|
|
|
if elem "nvidia" drivers then
|
2015-04-04 06:53:34 +02:00
|
|
|
|
kernelPackages.nvidia_x11
|
2016-03-07 23:25:59 +01:00
|
|
|
|
else if elem "nvidiaBeta" drivers then
|
|
|
|
|
kernelPackages.nvidia_x11_beta
|
2014-04-29 14:16:34 +02:00
|
|
|
|
else if elem "nvidiaLegacy173" drivers then
|
2015-02-21 16:29:36 +01:00
|
|
|
|
kernelPackages.nvidia_x11_legacy173
|
2014-05-13 18:35:57 +02:00
|
|
|
|
else if elem "nvidiaLegacy304" drivers then
|
2015-02-21 16:29:36 +01:00
|
|
|
|
kernelPackages.nvidia_x11_legacy304
|
2014-11-24 22:34:00 +01:00
|
|
|
|
else if elem "nvidiaLegacy340" drivers then
|
2015-02-21 16:29:36 +01: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 14:16:34 +02:00
|
|
|
|
|
2017-01-29 22:29:39 +01:00
|
|
|
|
nvidiaPackage = nvidia: pkgs:
|
|
|
|
|
if !nvidia.useGLVND then nvidia
|
|
|
|
|
else pkgs.buildEnv {
|
|
|
|
|
name = "nvidia-libs";
|
|
|
|
|
paths = [ pkgs.libglvnd nvidia.out ];
|
|
|
|
|
};
|
|
|
|
|
|
2015-02-21 16:29:36 +01:00
|
|
|
|
enabled = nvidia_x11 != null;
|
2014-04-29 14:16:34 +02:00
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
config = mkIf enabled {
|
|
|
|
|
|
|
|
|
|
services.xserver.drivers = singleton
|
2017-01-29 22:29:39 +01:00
|
|
|
|
{ name = "nvidia"; modules = [ nvidia_x11.bin ]; libPath = [ nvidia_x11 ]; };
|
2014-04-29 14:16:34 +02:00
|
|
|
|
|
|
|
|
|
services.xserver.screenSection =
|
|
|
|
|
''
|
|
|
|
|
Option "RandRRotation" "on"
|
|
|
|
|
'';
|
|
|
|
|
|
2017-02-11 15:11:18 +01:00
|
|
|
|
environment.etc."nvidia/nvidia-application-profiles-rc" = mkIf nvidia_x11.useProfiles {
|
|
|
|
|
source = "${nvidia_x11.bin}/share/nvidia/nvidia-application-profiles-rc";
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-29 22:29:39 +01:00
|
|
|
|
hardware.opengl.package = nvidiaPackage nvidia_x11 pkgs;
|
|
|
|
|
hardware.opengl.package32 = nvidiaPackage nvidia_libs32 pkgs_i686;
|
2014-04-29 14:16:34 +02:00
|
|
|
|
|
2017-01-29 22:29:39 +01:00
|
|
|
|
environment.systemPackages = [ nvidia_x11.bin nvidia_x11.settings nvidia_x11.persistenced ];
|
2014-04-29 14:16:34 +02:00
|
|
|
|
|
2017-01-29 22:29:39 +01:00
|
|
|
|
boot.extraModulePackages = [ nvidia_x11.bin ];
|
2014-04-29 14:16:34 +02:00
|
|
|
|
|
2015-03-03 20:15:38 +01:00
|
|
|
|
# nvidia-uvm is required by CUDA applications.
|
|
|
|
|
boot.kernelModules = [ "nvidia-uvm" ];
|
|
|
|
|
|
|
|
|
|
# Create /dev/nvidia-uvm when the nvidia-uvm module is loaded.
|
|
|
|
|
services.udev.extraRules =
|
|
|
|
|
''
|
|
|
|
|
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'"
|
|
|
|
|
'';
|
|
|
|
|
|
2014-04-29 14:16:34 +02:00
|
|
|
|
boot.blacklistedKernelModules = [ "nouveau" "nvidiafb" ];
|
|
|
|
|
|
|
|
|
|
services.acpid.enable = true;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|