Created
July 7, 2026 09:42
-
-
Save luxus/be5a72c4def21c946cae6c51ca1dee28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # NVIDIA drivers + CUDA — machines tagged gpu-nvidia | |
| # Supports Turing+ GPUs (RTX 2070, RTX 4090, etc.) with open kernel modules. | |
| { | |
| flake.modules.nixos.nvidia = | |
| { | |
| pkgs, | |
| config, | |
| ... | |
| }: | |
| { | |
| # allowUnfree is set once in modules/nixos/common.nix (always imported alongside this module). | |
| boot = { | |
| blacklistedKernelModules = [ "nouveau" ]; | |
| kernelParams = [ | |
| "nvidia_drm.modeset=1" | |
| "nvidia_drm.fbdev=1" | |
| "nvidia.NVreg_PreserveVideoMemoryAllocations=1" | |
| "nvidia.NVreg_TemporaryFilePath=/var/tmp" # Prevent tmpfs overflow on resume | |
| "nvidia.NVreg_EnableGpuFirmware=1" # GSP firmware offloading (Turing+) | |
| ]; | |
| }; | |
| hardware = { | |
| graphics = { | |
| enable = true; | |
| enable32Bit = true; | |
| extraPackages = with pkgs; [ | |
| nvidia-vaapi-driver | |
| libvdpau-va-gl | |
| ]; | |
| extraPackages32 = with pkgs.driversi686Linux; [ libvdpau-va-gl ]; | |
| }; | |
| nvidia-container-toolkit.enable = true; | |
| nvidia = { | |
| modesetting.enable = true; | |
| nvidiaSettings = true; | |
| open = true; | |
| powerManagement.enable = true; | |
| # Trying the "new_feature" branch (NVIDIA's current New Feature Branch). | |
| # This is newer (610.43.x) than the production/stable 595 series. | |
| # Revert to .stable (or .beta) if you hit instability, crashes, or regressions. | |
| package = config.boot.kernelPackages.nvidiaPackages.new_feature; | |
| }; | |
| }; | |
| # nvidia-container-toolkit-cdi-generator.service generates /run/cdi/nvidia.yaml | |
| # on boot so Podman/Docker can resolve nvidia.com/gpu=0 device requests. | |
| # The upstream NixOS service (hardware.nvidia-container-toolkit.enable = true above) | |
| # works correctly with the new_feature (610.43+) driver via NVML auto-detection. | |
| services.xserver.videoDrivers = [ "nvidia" ]; | |
| environment.sessionVariables = { | |
| LIBVA_DRIVER_NAME = "nvidia"; | |
| VDPAU_DRIVER = "va_gl"; | |
| GBM_BACKEND = "nvidia-drm"; | |
| __GLX_VENDOR_LIBRARY_NAME = "nvidia"; | |
| NVD_BACKEND = "direct"; | |
| __GL_GSYNC_ALLOWED = "1"; | |
| __GL_VRR_ALLOWED = "1"; | |
| NIXOS_OZONE_WL = "1"; | |
| ELECTRON_OZONE_PLATFORM_HINT = "wayland"; | |
| }; | |
| environment.systemPackages = with pkgs; [ | |
| libva | |
| libvdpau | |
| vdpauinfo | |
| libva-utils | |
| vulkan-tools | |
| mesa-demos | |
| ]; | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment