Seamless NVIDIA GTX 1080 Driver Installation on NixOS
Unlock Your GPU's Potential with Proprietary Drivers
Getting your NVIDIA GTX 1080 to work optimally with the proprietary drivers on NixOS, rather than the open-source Nouveau drivers, involves specific configuration steps within the NixOS framework. Due to NixOS's declarative nature and the proprietary status of NVIDIA's drivers, the process differs from traditional Linux distributions. This guide outlines the simplest and most effective approach to achieve this.
Key Highlights for NVIDIA Driver Configuration on NixOS
- Declare NVIDIA drivers in your configuration.nix: The core of the process involves enabling the proprietary NVIDIA drivers within your system's declarative configuration file.
- Handle unfree packages: NVIDIA drivers are proprietary, so you need to explicitly allow unfree packages in your NixOS configuration.
- Rebuild and switch your system: After modifying your configuration, you must rebuild and switch to the new system generation for the changes to take effect.
Understanding NixOS and Proprietary Drivers
NixOS manages packages and system configurations declaratively. This means your entire system state, including hardware drivers, is defined in configuration files (primarily configuration.nix). Unlike traditional distributions where you might install drivers using a package manager in a running system, NixOS requires you to declare the drivers as part of the system build process.
NVIDIA's drivers are proprietary and not open-source. NixOS, by default, discourages the use of unfree software. Therefore, to install the NVIDIA drivers, you need to explicitly permit the inclusion of unfree packages in your configuration.
Why Not Nouveau?
While Nouveau drivers are included with the Linux kernel and provide basic functionality for NVIDIA cards, the proprietary NVIDIA drivers generally offer significantly better performance, especially for gaming, CUDA applications, and other GPU-accelerated tasks. For a high-performance card like the GTX 1080, using the proprietary drivers is essential to unlock its full capabilities.
Users often report issues with Nouveau, including lower frame rates, lack of support for newer features, and problems with suspend/resume functionality, which are typically resolved by switching to the proprietary drivers.
The Simplest Configuration Steps
The most straightforward way to enable the proprietary NVIDIA drivers for your GTX 1080 on NixOS involves adding specific lines to your /etc/nixos/configuration.nix file.
Step 1: Allow Unfree Packages
Open your configuration.nix file with a text editor (like nano or vim). You need to add or ensure the following line is present to allow NixOS to fetch and build proprietary software, including the NVIDIA drivers:
nixpkgs.config.allowUnfree = true;
This line should typically be placed near the top of your file or within the nixpkgs.config block if one exists.
Step 2: Configure the NVIDIA Driver
Next, you need to tell NixOS to use the NVIDIA driver for your graphics server. Add the following lines to your configuration.nix:
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia.modesetting.enable = true;
hardware.opengl.enable = true;
hardware.opengl.driSupport32Bit = true; # Recommended for 32-bit applications (e.g., some games)
hardware.nvidia.nvidiaSettings = true; # Recommended for accessing NVIDIA settings utility
Let's break down these options:
-
services.xserver.videoDrivers = [ "nvidia" ];: This tells your display server (X server) to use the NVIDIA driver. -
hardware.nvidia.modesetting.enable = true;: Enables NVIDIA modesetting, which is crucial for proper display output and performance, especially with modern desktop environments. -
hardware.opengl.enable = true;: Enables OpenGL support, necessary for 3D rendering and many applications. -
hardware.opengl.driSupport32Bit = true;: Provides 32-bit DRI (Direct Rendering Infrastructure) support, often required for running 32-bit applications, including many games, on a 64-bit system. -
hardware.nvidia.nvidiaSettings = true;: Installs thenvidia-settingsutility, which allows you to configure various NVIDIA driver settings.
Step 3: Consider Hybrid Graphics (If Applicable)
If your system has both an integrated Intel or AMD GPU and the discrete NVIDIA GTX 1080 (a hybrid graphics setup, often found in laptops), you might need additional configuration to use NVIDIA PRIME for offloading or using the NVIDIA card as the primary GPU. For a desktop with only the GTX 1080, the above steps should suffice.
For hybrid graphics, you might add:
hardware.nvidia.prime = {
offload.enable = true; # Enable PRIME Render Offload
# busId = "PCI:1:0:0"; # Optional: Specify the bus ID of the NVIDIA GPU
# intelBusId = "PCI:0:2:0"; # Optional: Specify the bus ID of the integrated GPU
};
You can find the Bus ID values using commands like lspci -nn | grep -i vga or lshw -c display. Identifying the correct bus IDs is crucial for hybrid graphics configurations.
Example image related to potential display issues when configuring NVIDIA drivers.
Step 4: Rebuild and Switch
After saving the changes to your configuration.nix, you need to rebuild your NixOS system and switch to the new configuration. Open a terminal and run:
sudo nixos-rebuild switch
NixOS will then build the new system generation with the specified NVIDIA drivers. If the build is successful, it will switch to this new configuration. If there are errors, the command will usually provide output indicating what went wrong. You can revert to a previous working generation if needed using sudo nixos-rebuild switch --rollback.
Step 5: Reboot
After a successful rebuild and switch, it's highly recommended to reboot your system to ensure the new drivers are loaded correctly by the kernel and display server.
Verifying the Installation
Once your system has rebooted, you can verify that the proprietary NVIDIA drivers are in use.
Using nvidia-smi
Open a terminal and run the command nvidia-smi. This utility should display information about your NVIDIA GPU and the installed driver version. If this command is not found, ensure you included hardware.nvidia.nvidiaSettings = true; in your configuration.
nvidia-smi
Checking with glxinfo
You can also check OpenGL rendering information using glxinfo. Install mesa-utils if you don't have it:
nix-env -iA nixos.mesa-utils
Then run glxinfo | grep "OpenGL vendor" and glxinfo | grep "OpenGL renderer". The output should indicate NVIDIA as the vendor and list your GTX 1080 as the renderer.
Troubleshooting Common Issues
While the process is generally straightforward, you might encounter some issues:
Black Screen on Boot
A black screen after switching configurations is a common problem with NVIDIA drivers if they are not configured correctly or conflict with other settings. This often indicates that the display server (Xorg or Wayland) failed to start with the NVIDIA driver. If this happens, you can usually drop to a TTY (text-mode console) by pressing Ctrl + Alt + F3 to F7.
From the TTY, you can log in and check the system journal for errors:
journalctl -xe
You can also revert to the previous working system generation:
sudo nixos-rebuild switch --rollback
Review your configuration.nix carefully for typos or incorrect options.
Driver Version Conflicts
NixOS channels provide specific versions of the NVIDIA drivers that are tested to work with the corresponding kernel version in that channel. Sticking to the drivers provided by your current NixOS channel (e.g., nixos-23.11, nixos-24.05, or nixos-unstable) is usually the most stable approach.
You can check the available driver version in your channel using the Nix package search online or with nix search nixos-wip nvidia-drivers (replace nixos-wip with your channel if needed). While it's possible to try different driver versions, it adds complexity and is generally not the "simplest" way.
Wayland vs. Xorg
Support for NVIDIA drivers on Wayland has improved but can still have issues compared to Xorg, depending on the desktop environment and specific NVIDIA features used. If you are having display issues with Wayland, you might try switching to Xorg to see if the problem is resolved.
You can often configure your display manager (like GDM or LightDM) to use Xorg sessions instead of Wayland.
Advanced Configurations (Optional)
While the basic steps cover the simplest installation, NixOS offers more granular control:
Specifying a Specific Driver Package
If you need a particular NVIDIA driver version not the default for your channel, you can specify the package explicitly. This is generally not recommended for simplicity unless you have a specific reason.
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.production; # Example for the production branch
# Or for a specific version (less common):
# hardware.nvidia.package = pkgs.cudaPackages.nvidia_535;
Finding the correct package name and ensuring compatibility requires more advanced knowledge of the Nix package ecosystem.
Kernel Modules
The necessary kernel modules (nvidia, nvidia_modeset, nvidia_uvm, nvidia_drm) are typically loaded automatically when you enable the driver. However, in some complex setups (like GPU passthrough), you might need to explicitly manage kernel modules and their load order.
boot.initrd.kernelModules = [ "nvidia" "nvidia_drm" "nvidia_modeset" "nvidia_uvm" ];
boot.extraModulePackages = with config.boot.kernelPackages; [ nvidia_x11 ]; # Ensure nvidia_x11 is built/available
This level of configuration is beyond the "simplest" method but illustrates the control NixOS provides.
This video discusses the suitability of NixOS for gaming, which often involves optimizing graphics driver performance with cards like the GTX 1080.
Summary of Essential Configuration
To summarize the minimal configuration for getting your GTX 1080 working with proprietary drivers on NixOS, your /etc/nixos/configuration.nix should include at least these lines:
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
services.xserver.enable = true; # Ensure X server is enabled
services.xserver.displayManager.lightdm.enable = true; # Or your preferred display manager
services.xserver.desktopManager.gnome.enable = true; # Or your preferred desktop environment
# Configure NVIDIA drivers
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia.modesetting.enable = true;
hardware.opengl.enable = true;
hardware.opengl.driSupport32Bit = true;
hardware.nvidia.nvidiaSettings = true;
Remember to replace lightdm.enable = true; and gnome.enable = true; with your actual display manager and desktop environment if they are different.
Frequently Asked Questions
What if I get a black screen after rebuilding?
Try dropping to a TTY (Ctrl + Alt + F3 to F7), logging in, and running sudo nixos-rebuild switch --rollback to return to your previous working configuration. Then, carefully review your configuration.nix for errors, especially in the services.xserver and hardware.nvidia sections.
Do I need to manually download drivers from NVIDIA's website?
No, the strength of NixOS is that it manages dependencies and packages for you. By specifying services.xserver.videoDrivers = [ "nvidia" ]; and allowing unfree packages, NixOS automatically fetches and builds the appropriate NVIDIA driver package from the Nix package repositories that is compatible with your kernel.
How do I update the NVIDIA drivers?
To update your drivers, you update your NixOS channel and then rebuild your system. NixOS will automatically pull in the newer driver version available in the updated channel. For example, to update the unstable channel:
sudo nix channel --update nixos-unstable
sudo nixos-rebuild switch
For stable channels, the process is similar after updating the channel.
Can I use the open-source NVIDIA drivers (hardware.nvidia.open = true;)?
NixOS does offer an option for open-source NVIDIA kernel modules (hardware.nvidia.open = true;). However, for desktop usage and optimal performance with a GTX 1080, the proprietary drivers (hardware.nvidia.open = false;, which is the default when you just enable services.xserver.videoDrivers = [ "nvidia" ];) are generally recommended and provide better support for graphics acceleration.
My system has both Intel integrated graphics and the NVIDIA card. How do I configure that?
This is a hybrid graphics setup. The simplest way is to use NVIDIA PRIME render offload, as mentioned in Step 3. This allows the integrated GPU to handle the display while offloading demanding graphics tasks to the NVIDIA card. Ensure you identify the correct bus IDs for both GPUs using lshw -c display.
References
Last updated May 1, 2025