# Installing NVIDIA Drivers on a Laptop in NixOS

**URL:** https://discourse.nixos.org/t/installing-nvidia-drivers-on-a-laptop-in-nixos/70951
**Category:** Guides
**Created:** [October 16, 2025, 11:53am UTC](https://discourse.nixos.org/t/installing-nvidia-drivers-on-a-laptop-in-nixos/70951 "2025-10-16T11:53:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chvanin](https://discourse.nixos.org/user_avatar/discourse.nixos.org/chvanin/32/34744_2.png) [@chvanin](https://discourse.nixos.org/u/chvanin)
#### Post date: [October 16, 2025, 11:53am UTC](https://discourse.nixos.org/t/installing-nvidia-drivers-on-a-laptop-in-nixos/70951/1 "2025-10-16T11:53:58Z")

</div>

Warning for readers: my main language is Russian, the translation may be incorrect in some places. Have fun reading.

This guide walks through the process of configuring NVIDIA proprietary drivers on a NixOS laptop with a hybrid graphics setup (a dedicated NVIDIA GPU and an integrated Intel GPU). Our specific hardware was a laptop with an NVIDIA **GeForce GTX 1650 Ti** and an **Intel Core i5-10300H**.

The journey involved several common errors and a final switch to a more stable configuration mode.

Step 1: Find Your GPU Bus IDs  
For laptops with hybrid graphics, you must tell NixOS the PCI Bus IDs of both your integrated and dedicated GPUs.

1. Open a terminal.

2. The `lspci` command is not installed by default. Run it within a temporary shell:

3. Once inside the `nix-shell`, run the command to find your graphics devices:

4. You will get an output similar to this. Note the values at the beginning of each line (e.g., `00:02.0` and `01:00.0`).

5. Convert these IDs to the format `PCI:BUS:SLOT:FUNCTION`. For our example, this becomes:

6. Type `exit` to leave the `nix-shell`.

Step 2: Initial Configuration Attempt (PRIME Offload)

Our first goal was to use **PRIME Offload** , a mode that saves battery by keeping the NVIDIA GPU powered down until it’s explicitly needed.

Here is the initial configuration block we added to `configuration.nix`:

```nix
# Enable OpenGL
hardware.graphics = {
  enable = true;
  enable32Bit = true;
};

# Configure the NVIDIA driver
hardware.nvidia = {
  modesetting.enable = true;
  open = true; # Use the open-source kernel module
  nvidiaSettings = true;
  package = config.boot.kernelPackages.nvidiaPackages.stable;
  
  prime = {
    offload = {
      enable = true;
      enableOffloadCmd = true;
    };
    # Use the Bus IDs you found earlier
    intelBusId = "PCI:0:2:0";
    nvidiaBusId = "PCI:1:0:0";
  };
};

# Load the nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = ["modesetting" "nvidia"];

```

## Troubleshooting: The Errors We Encountered

Applying the initial configuration was not smooth. Here are the errors we faced and how we fixed them.

#### Error 1: `hardware.opengl.videoDrivers’ does not exist

- **Problem:** This option has been renamed.
- **Solution:** We changed `hardware.opengl.videoDrivers` to `services.xserver.videoDrivers`.

#### Error 2: `hardware.opengl.driSupport’ no longer has any effect

- **Problem:** This option is now enabled automatically when `hardware.opengl.enable` is set to `true`.
- **Solution:** We simply removed the `driSupport = true;` line from our configuration.

#### Error 3: Syntax Error, unexpected `=`

- **Problem:** A simple typo where we wrote `package = package = ...`.
- **Solution:** We corrected the line to `package = config.boot.kernelPackages.nvidiaPackages.stable;`.

#### Error 4: attribute ‘production\_open’ missing

- **Problem:** We tried to use a package name (`production_open`) that doesn’t exist in this NixOS version.
- **Solution:** We used the standard `stable` package and relied on the `open = true;` flag to select the correct variant.

#### Problem 5: The X11 Login Loop

- **Problem:** After rebuilding, we could log in to the Wayland session, but trying to log into the “Plasma (X11)” session would show a black screen and return us to the login prompt. This is a classic “login loop”.
- **Root Cause:** PRIME Offload can be complex to configure and sometimes conflicts with the X server startup.

## Step 3: The Final Solution - Switching to PRIME Sync

To solve the login loop, we switched from `Offload` mode to **PRIME Sync**. This mode is less power-efficient but significantly more stable and easier to configure. It uses the NVIDIA GPU for all rendering and simply displays the final image on the screen.

1. We modified the `hardware.nvidia.prime` block in our `configuration.nix`:

2. We also removed `"modesetting"` from the `videoDrivers` list for maximum compatibility with X11:

3. We ran `sudo nixos-rebuild switch` and rebooted.

## The Final Working Configuration

This is the final, working `hardware.nvidia` block that successfully configured our system:

```nix
# === NVIDIA CONFIGURATION FOR LAPTOP ===
hardware.graphics = {
  enable = true;
  enable32Bit = true;
};

services.xserver.videoDrivers = ["nvidia"];

hardware.nvidia = {
  modesetting.enable = true;
  open = true;
  nvidiaSettings = true;
  package = config.boot.kernelPackages.nvidiaPackages.stable;

  prime = {
    sync.enable = true; # The stable solution
    intelBusId = "PCI:0:2:0";
    nvidiaBusId = "PCI:1:0:0";
  };
};
# === END OF NVIDIA CONFIGURATION ===

```

## Verification

After rebooting and logging into the “Plasma (X11)” session, we verified the installation by opening a terminal and running:

```bash
nvidia-smi

```

This command displayed a detailed table with our GTX 1650 Ti’s information, confirming that the driver was active and correctly configured. Games and applications now use the NVIDIA GPU by default.

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [October 16, 2025, 7:16pm UTC](https://discourse.nixos.org/t/installing-nvidia-drivers-on-a-laptop-in-nixos/70951/2 "2025-10-16T19:16:22Z")

</div>

Good attempt. This is _approaching_ a correct setup, however:

> [@chvanin](#):
>
> ```auto
> modesetting.enable = true;
> open = true; # Use the open-source kernel module
> nvidiaSettings = true;
> package = config.boot.kernelPackages.nvidiaPackages.stable;
> 
> ```

These are default settings, omit them.

> [@chvanin](#):
>
> Step 3: The Final Solution - Switching to PRIME Sync

This is almost certainly _not_ how you fixed the X11 “boot loop”. It was doing:

> [@chvanin](#):
>
> We also removed `"modesetting"` from the `videoDrivers` list for maximum compatibility with X11:

This has nothing to do with X11 compat; Adding the `modesetting` driver simply breaks your setup (since X11 will be configured to use nvidia but your iGPU will be driving the actual display). You can likely just disable `sync.enable` at this point and it’ll work.

When using prime offload, you need to use the `nvidia-offload` command to start any applications you want to run on the nvidia GPU. You can override your `.desktop` files to make this automatic for specific applications, by setting [the environment variables it configures](https://github.com/NixOS/nixpkgs/blob/a493e93b4a259cd9fea8073f89a7ed9b1c5a1da2/nixos/modules/hardware/video/nvidia.nix#L570) as part of the `.desktop` file.

Also note that none of this works on wayland (hence the “X11 compat” comment makes no sense ;p); for that you need compositor-specific configuration. I have [a module](https://github.com/TLATER/dotfiles/blob/7388c6317525c94af0c3f688b274b7b4a2253925/nixos-modules/nvidia/de-compat.nix) (also needs [this udev rule](https://github.com/TLATER/dotfiles/blob/7388c6317525c94af0c3f688b274b7b4a2253925/nixos-modules/nvidia/prime.nix#L41)) that sets that up for the compositors I know about. This doesn’t include Hyprland.

---

<div class="post-metadata">

### Author: ![chvanin](https://discourse.nixos.org/user_avatar/discourse.nixos.org/chvanin/32/34744_2.png) [@chvanin](https://discourse.nixos.org/u/chvanin)
#### Post date: [October 16, 2025, 7:30pm UTC](https://discourse.nixos.org/t/installing-nvidia-drivers-on-a-laptop-in-nixos/70951/3 "2025-10-16T19:30:54Z")

</div>

Good catch on the modesetting conflict. You’re right, that’s the real fix.

As I just installed NixOS today, I’ll leave the original guide as-is to document the beginner’s journey. Your comment serves as the perfect technical clarification and correction for anyone who finds this thread.

Appreciate you taking the time to write this out.
