2024-03-03 16:13:56 -05:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
2024-06-24 12:30:49 -04:00
|
|
|
inherit (lib) mkIf mkEnableOption mkOption optionals types;
|
2024-03-03 16:13:56 -05:00
|
|
|
|
|
|
|
cfg = config.nvidia;
|
|
|
|
in {
|
|
|
|
options.nvidia = {
|
2024-06-24 12:30:49 -04:00
|
|
|
enable = mkEnableOption "nvidia";
|
2024-03-03 16:13:56 -05:00
|
|
|
|
|
|
|
enableNvidiaSettings = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
enableWayland = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
enableCUDA = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-06-21 18:15:19 -04:00
|
|
|
hardware.graphics = {
|
2024-03-03 16:13:56 -05:00
|
|
|
enable = true;
|
2024-06-21 18:15:19 -04:00
|
|
|
enable32Bit = true;
|
2024-03-03 16:13:56 -05:00
|
|
|
|
|
|
|
extraPackages = with pkgs; [
|
|
|
|
vaapiVdpau
|
|
|
|
libvdpau-va-gl
|
|
|
|
nvidia-vaapi-driver
|
|
|
|
];
|
|
|
|
extraPackages32 = with pkgs; [vaapiVdpau];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.xserver.videoDrivers = ["nvidia"];
|
|
|
|
|
|
|
|
hardware.nvidia = {
|
|
|
|
modesetting.enable = true;
|
|
|
|
|
|
|
|
# Enable the Nvidia settings menu,
|
|
|
|
# accessible via `nvidia-settings`.
|
|
|
|
nvidiaSettings = cfg.enableNvidiaSettings;
|
|
|
|
|
|
|
|
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
|
|
|
|
powerManagement = {
|
|
|
|
enable = false;
|
|
|
|
|
|
|
|
# Fine-grained power management. Turns off GPU when not in use.
|
|
|
|
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
|
|
|
|
finegrained = false;
|
|
|
|
};
|
|
|
|
|
2024-06-15 01:40:26 -04:00
|
|
|
open = false;
|
2024-03-03 16:13:56 -05:00
|
|
|
|
2024-05-05 23:07:06 -04:00
|
|
|
package =
|
2024-03-13 19:25:48 -04:00
|
|
|
if !cfg.enableWayland
|
2024-05-05 23:07:06 -04:00
|
|
|
then config.boot.kernelPackages.nvidiaPackages.stable
|
2024-05-22 10:24:21 -04:00
|
|
|
else
|
|
|
|
# Get newest beta driver version for better Wayland support
|
|
|
|
config.boot.kernelPackages.nvidiaPackages.mkDriver {
|
2024-06-28 02:06:10 -04:00
|
|
|
version = "555.58";
|
|
|
|
sha256_64bit = "sha256-bXvcXkg2kQZuCNKRZM5QoTaTjF4l2TtrsKUvyicj5ew=";
|
|
|
|
sha256_aarch64 = "sha256-7XswQwW1iFP4ji5mbRQ6PVEhD4SGWpjUJe1o8zoXYRE=";
|
|
|
|
openSha256 = "sha256-hEAmFISMuXm8tbsrB+WiUcEFuSGRNZ37aKWvf0WJ2/c=";
|
|
|
|
settingsSha256 = "sha256-vWnrXlBCb3K5uVkDFmJDVq51wrCoqgPF03lSjZOuU8M=";
|
|
|
|
persistencedSha256 = "sha256-lyYxDuGDTMdGxX3CaiWUh1IQuQlkI2hPEs5LI20vEVw=";
|
2024-03-13 19:25:48 -04:00
|
|
|
};
|
2024-03-03 16:13:56 -05:00
|
|
|
};
|
|
|
|
|
2024-05-05 23:07:06 -04:00
|
|
|
environment.systemPackages =
|
|
|
|
optionals cfg.enableCUDA [pkgs.cudaPackages.cudatoolkit]
|
|
|
|
++ (with pkgs; [
|
2024-03-03 16:13:56 -05:00
|
|
|
libva-utils
|
|
|
|
nvidia-vaapi-driver
|
2024-03-22 21:10:11 -04:00
|
|
|
nvtopPackages.nvidia
|
2024-03-03 16:13:56 -05:00
|
|
|
pciutils
|
|
|
|
vdpauinfo
|
2024-05-05 23:07:06 -04:00
|
|
|
]);
|
2024-03-03 16:13:56 -05:00
|
|
|
|
2024-06-15 01:40:26 -04:00
|
|
|
boot.kernelModules =
|
|
|
|
optionals cfg.enableCUDA ["nvidia-uvm"]
|
|
|
|
++ ["nvidia" "nvidia-drm"];
|
2024-03-03 16:13:56 -05:00
|
|
|
};
|
|
|
|
}
|