From e039341a3ddfd45241f8260fed9fec9d981917b1 Mon Sep 17 00:00:00 2001 From: David Crompton Date: Tue, 1 Aug 2023 12:48:49 -0400 Subject: [PATCH] Add NVIDIA & CUDA Cachix Substituter --- machines/kcnhub/configuration.nix | 2 ++ machines/kcnhub/nvidia.nix | 45 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 machines/kcnhub/nvidia.nix diff --git a/machines/kcnhub/configuration.nix b/machines/kcnhub/configuration.nix index 4c33354..0414e1e 100644 --- a/machines/kcnhub/configuration.nix +++ b/machines/kcnhub/configuration.nix @@ -4,6 +4,8 @@ imports = [ ./hardware-configuration.nix + # Enable Nvidia driver and CUDA + ./nvidia.nix # Set of Modules Defining System Configuration ./modules.nix # Set of system services, like ssh, and RDP/VNC diff --git a/machines/kcnhub/nvidia.nix b/machines/kcnhub/nvidia.nix new file mode 100644 index 0000000..9e68223 --- /dev/null +++ b/machines/kcnhub/nvidia.nix @@ -0,0 +1,45 @@ +{ config, lib, pkgs, ...}: { + # Make sure opengl is enabled + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + + # Tell Xorg to use the nvidia driver (also valid for Wayland) + services.xserver.videoDrivers = [ + # For the RTX 4000 + "nvidia" + # For the Older GPU + "nouveau" + ]; + + hardware.nvidia = { + + # Modesetting is needed for most Wayland compositors + modesetting.enable = true; + + # Use the open source version of the kernel module + # Only available on driver 515.43.04+ + open = true; + + # Enable the nvidia settings menu + nvidiaSettings = true; + + # Optionally, you may need to select the appropriate driver version for your specific GPU. + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + + # Allow Unfree, Nvidia, CUDA, and derived packages. + nixpkgs.config.allowUnfree = true; + + # Use Prebuilt Cached Versions of CUDA Packages + nix.settings = { + trusted-substituters = [ + "https://cuda-maintainers.cachix.org" + ]; + trusted-public-keys = [ + "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=" + ]; + }; +}