# Using nvidia open-source drivers

**URL:** https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809
**Category:** Help
**Created:** [May 2, 2023, 11:24am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809 "2023-05-02T11:24:00Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![mounty](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mounty](https://discourse.nixos.org/u/mounty)
#### Post date: [May 2, 2023, 11:24am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/1 "2023-05-02T11:24:00Z")

</div>

Since I didn’t really understand what action to take in [my last question](https://discourse.nixos.org/t/graphics-unworkable-with-22-11-optimus-nvidia/26041/13) I’m still stuck with a Lenovo W520 that runs rather slowly with 22.11. The Nouveau drivers don’t work (they drive only the two external screens, leaving the laptop’s own display blank) so I wondered about the Nvidia open-source drivers. There’s a reference to them [here](https://www.reddit.com/r/NixOS/comments/zkdnru/how_can_i_install_open_source_drivers_on_nixos/) but what actually do I have to change in /etc/nixos/configuration.nix to use the open source drivers? My configuration is [this](https://github.com/mounty1/NixOS-W520-config/tree/22.11) and my kernel is 5.15, so I suppose [linuxKernel.packages.linux\_5\_15.nvidia\_x11\_production\_open](https://search.nixos.org/packages?channel=22.11&show=linuxKernel.packages.hardkernel_4_14.nvidia_x11_beta_open&from=50&size=50&sort=relevance&type=packages&query=nvidia-open) is the one I want but where does that go in /etc/nixos/configuration.nix?

---

<div class="post-metadata">

### Author: ![user2358](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/u/8797f3/32.png) [@user2358](https://discourse.nixos.org/u/user2358)
#### Post date: [May 2, 2023, 2:58pm UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/2 "2023-05-02T14:58:00Z")

</div>

From a blog that I read a while ago [https://www.howtogeek.com/805004/nvidia-releases-open-source-linux-gpu-drivers-with-a-catch/](https://www.howtogeek.com/805004/nvidia-releases-open-source-linux-gpu-drivers-with-a-catch/), it said the open-source driver only supports graphics cards that use Nvidia’s [Ampere](https://en.wikipedia.org/wiki/Ampere_(microarchitecture)) and [Turing](https://en.wikipedia.org/wiki/Turing_(microarchitecture)) architectures, which includes the GeForce 16-series, RTX 20-series, and newer GPUs. Anyone with a GTX 10-series card or other older hardware don’t have access to the new driver at all. So I’m not sure how nvidia open source drivers will help here.

---

<div class="post-metadata">

### Author: ![emmanuelrosa](https://discourse.nixos.org/user_avatar/discourse.nixos.org/emmanuelrosa/32/1924_2.png) [@emmanuelrosa](https://discourse.nixos.org/u/emmanuelrosa)
#### Post date: [May 2, 2023, 3:59pm UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/3 "2023-05-02T15:59:40Z")

</div>

I suspect that optimus just doesn’t work on Linux with your W520. I think your best bet is:

1. Configure Xorg to use only your NVIDIA dGPU; See the first example on [Nvidia - NixOS Wiki](https://nixos.wiki/wiki/Nvidia)
2. Build NixOS and set this new configuration to boot: `nixos-rebuild boot`
3. Reboot and go into the BIOS and make the NVIDIA dGPU the default: Config → Display → Graphics Device → Discrete Graphics
4. Cross your fingers and boot into NixOS.

---

<div class="post-metadata">

### Author: ![mounty](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mounty](https://discourse.nixos.org/u/mounty)
#### Post date: [May 2, 2023, 8:19pm UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/4 "2023-05-02T20:19:13Z")

</div>

It worked perfectly with 21.11.

---

<div class="post-metadata">

### Author: ![NickCao](https://discourse.nixos.org/user_avatar/discourse.nixos.org/nickcao/32/4433_2.png) [@NickCao](https://discourse.nixos.org/u/NickCao)
#### Post date: [May 3, 2023, 2:09am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/5 "2023-05-03T02:09:45Z")

</div>

If you want to use the official opensource nvidia driver, just configure everything else as usual, then flip `hardware.nvidia.open` to `true`. Still as suggested by @user2358, it has limited hardware support and is not as feature rich as the proprietary one.

---

<div class="post-metadata">

### Author: ![mounty](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mounty](https://discourse.nixos.org/u/mounty)
#### Post date: [May 3, 2023, 2:40am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/6 "2023-05-03T02:40:08Z")

</div>

Sorry to be dim but I’m not clear what you mean by _configure everything as usual_. Do you mean just insert in [my configuration](https://github.com/mounty1/NixOS-W520-config/blob/2bb452c2770e769fabfdf3b350adacc30c411039/nvidia.nix) a line

```
open = true;

```

at about line 12?

Or (more likely, now I think about it), exclude that file altogether from the configuration, and include just the declaration `hardware.nvidia.open = true;` in my configuration.nix ?

---

<div class="post-metadata">

### Author: ![NickCao](https://discourse.nixos.org/user_avatar/discourse.nixos.org/nickcao/32/4433_2.png) [@NickCao](https://discourse.nixos.org/u/NickCao)
#### Post date: [May 3, 2023, 2:55am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/7 "2023-05-03T02:55:52Z")

</div>

As usual means leaving your current configuration as is, only adding the single line for `open`.

---

<div class="post-metadata">

### Author: ![mounty](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mounty](https://discourse.nixos.org/u/mounty)
#### Post date: [May 3, 2023, 3:03am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/8 "2023-05-03T03:03:17Z")

</div>

OK, I wasn’t certain because [part of my current configuration](https://github.com/mounty1/NixOS-W520-config/blob/2bb452c2770e769fabfdf3b350adacc30c411039/nvidia.nix) seems to specify the proprietary drivers. I’ll just add the `hardware.nvidia.open = true;` declaration to that file.

---

<div class="post-metadata">

### Author: ![NickCao](https://discourse.nixos.org/user_avatar/discourse.nixos.org/nickcao/32/4433_2.png) [@NickCao](https://discourse.nixos.org/u/NickCao)
#### Post date: [May 3, 2023, 3:16am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/9 "2023-05-03T03:16:22Z")

</div>

You’d better check if your hardware is supported by the open source driver first (a full list is at [GitHub - NVIDIA/open-gpu-kernel-modules: NVIDIA Linux open GPU kernel module source](https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus)), that would likely be a no as you are now using the `legacy_390` driver.

---

<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: [May 3, 2023, 11:38am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/10 "2023-05-03T11:38:41Z")

</div>

Yeah, the new drivers should not be usable for your GPU either. ooi, when you used nouveau, what was your configuration? It supposedly doesn’t use the same variables as nvidia to manage offload rendering, and I imagine the prime options are either noops or problematic.

I suspect by the symptoms that you ended up just using the nvidia GPU. What does `glxinfo` give you when using the nouveau driver?

Nouveau still [doesn’t have powermanagement](https://nouveau.freedesktop.org/FeatureMatrix.html) for anything though, you probably won’t have a fun time with it either. I think your best bet is just using the proprietary driver in sync mode, which I _think_ it’s capable of (?).

---

<div class="post-metadata">

### Author: ![mounty](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mounty](https://discourse.nixos.org/u/mounty)
#### Post date: [May 12, 2023, 8:59am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/11 "2023-05-12T08:59:42Z")

</div>

As I’ve mentioned twice already, my current configuration is [here](https://github.com/mounty1/NixOS-W520-config/blob/2bb452c2770e769fabfdf3b350adacc30c411039/nvidia.nix).

---

<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: [May 12, 2023, 11:23am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/12 "2023-05-12T11:23:56Z")

</div>

Yep, I saw that, but that configuration isn’t using nouveau, and afaict there is no branch with nouveau either, so I can’t see what your configuration was when you were using it.

Looking at the [nouveau documentation for optimus](https://nouveau.freedesktop.org/Optimus.html), and the [NixOS implementation](https://github.com/NixOS/nixpkgs/blob/a08e061a4ee8329747d54ddf1566d34c55c895eb/nixos/modules/hardware/video/nvidia.nix), NixOS currently just doesn’t support nouveau for offload rendering. It in fact blacklists the nouveau driver, which is probably why one of your displays isn’t working.

---

<div class="post-metadata">

### Author: ![mounty](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mounty](https://discourse.nixos.org/u/mounty)
#### Post date: [May 12, 2023, 8:45pm UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/13 "2023-05-12T20:45:21Z")

</div>

Sorry for my bluntness and thank you for your patience in the face of it. It is borne of frustration that Nvidia _used_ to work perfectly, with 21.11, but for other reasons I could not just stay on that release.

The 22.11 Nouveau configuration is [here](https://github.com/mounty1/NixOS-W520-config/tree/22.11-nouveau). The fault is that it drives only the two external displays; the laptop display is blank, although with a text-mode blinking input caret at the top-left. Oh, and the 4k screen appears to be scaled to FHD, not in its native resolution.

The official closed-source drivers do kind-of work, but they suck CPU (the laptop fan runs constantly) and one external screen blinks every ten seconds or so. I can ameliorate the CPU load by `renice` on the X process but `top` doesn’t show anything else sucking CPU so it must be kernel + drivers.

---

<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: [May 13, 2023, 12:57am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/14 "2023-05-13T00:57:23Z")

</div>

If you’re completely stuck, maybe you can slowly bisect to see what upstream commit broke things? instead of going to 22.11 immediately, starting by going to 22.05, and then going only by commits (binary search style).

---

<div class="post-metadata">

### Author: ![mounty](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mounty](https://discourse.nixos.org/u/mounty)
#### Post date: [May 13, 2023, 6:24am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/15 "2023-05-13T06:24:38Z")

</div>

I don’t really have the time to get into that. I’ll just put up with it and try Nouveau every six months or so. Thanks again for your help.

---

<div class="post-metadata">

### Author: ![mounty](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mounty](https://discourse.nixos.org/u/mounty)
#### Post date: [May 15, 2023, 9:11pm UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/16 "2023-05-15T21:11:30Z")

</div>

I did find the time to install 22.05. It fixes the problem. 22.11 was almost workably slow but 22.05 works just fine.  
_TLater_ mentions bisecting. How does that work with NixOS, where so far as I am aware, the only method of updating is `nixos-rebuild` ?

---

<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: [May 15, 2023, 9:34pm UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/17 "2023-05-15T21:34:25Z")

</div>

You’ve effectively already started; bisecting is just the process of building various commits (in a binary search-like pattern) until you find the one that causes it, using some specific git tooling to help do this.

You can use [nix-bisect](https://github.com/timokau/nix-bisect) for that. There’s an announcement for it here with some additional info: [Nix-bisect -- Bisect Nix Builds](https://discourse.nixos.org/t/nix-bisect-bisect-nix-builds/5584)

---

<div class="post-metadata">

### Author: ![mounty](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mounty](https://discourse.nixos.org/u/mounty)
#### Post date: [June 14, 2023, 9:29am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/18 "2023-06-14T09:29:32Z")

</div>

It seems to me it’s going to be difficult to use git-bisect because I can’t really write a test that git can find. I can only to bisect onto the problem commit myself, as I have to log in to the desktop and run it for a couple of minutes to work out whether or not the problem is present.  
I have here a W520 running 22.05 and doing so well. I understand that rather than using `nixos-rebuild switch --upgrade` I can somehow use git commands to bisect between 22.05 and 22.11. Can you give me some pointers on that, since I was not even aware that nix packages were stored in a versioned repository.

---

<div class="post-metadata">

### Author: ![iFreilicht](https://discourse.nixos.org/user_avatar/discourse.nixos.org/ifreilicht/32/9702_2.png) [@iFreilicht](https://discourse.nixos.org/u/iFreilicht)
#### Post date: [June 14, 2023, 10:36am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/19 "2023-06-14T10:36:38Z")

</div>

I don’t think you necessarily need to use git here, you can just “upgrade” to intermediate unstable revisions between 22.05 and 22.11 to find the revision that broke the drivers for you.

Basically what `nixos-rebuild switch --upgrade` does is to upgrade the root channel before running `nixos-rebuild switch` normally. You can just set the channel to specific revisions, rebuild, and see if the drivers work or not.

Could you show your output of `sudo nix-channel --list` and `nix-channel --list`? Just so I can give you more correct instructions.

Also be aware that [23.05 was released in the meantime](https://discourse.nixos.org/t/nixos-23-05-released/28649), so if you try upgrading once more, maybe you’re lucky and it’s fixed again?

Additionally, in case you don’t want to put in the effort into bisecting and just want a working system with the latest software otherwise, you can install older working drivers on a new release of NixOS as well.

---

<div class="post-metadata">

### Author: ![mounty](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mounty](https://discourse.nixos.org/u/mounty)
#### Post date: [June 16, 2023, 9:11am UTC](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809/20 "2023-06-16T09:11:18Z")

</div>

I did try 23.05 and the problem is not fixed, so here goes:

```
[mounty@pingala:~]$ sudo nix-channel --list
nixos https://nixos.org/channels/nixos-22.05

[mounty@pingala:~]$ nix-channel --list

[mounty@pingala:~]$

```

Thank you.

[Next page](https://discourse.nixos.org/t/using-nvidia-open-source-drivers/27809.md?page=2)
