Skip to content

Commit

Permalink
Lenovo Legion 16achg6 support (#796)
Browse files Browse the repository at this point in the history
  • Loading branch information
bratfizyk authored Dec 13, 2023
1 parent fef05bf commit 7763c6f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ See code for all available configurations.
| [Lenovo Legion 5 Pro 16ach6h](lenovo/legion/16ach6h) | `<nixos-hardware/lenovo/legion/16ach6h>` |
| [Lenovo Legion 5 Pro 16ach6h (Hybrid)](lenovo/legion/16ach6h/hybrid)| `<nixos-hardware/lenovo/legion/16ach6h/hybrid>` |
| [Lenovo Legion 5 Pro 16ach6h (Nvidia)](lenovo/legion/16ach6h/nvidia)| `<nixos-hardware/lenovo/legion/16ach6h/nvidia>` |
| [Lenovo Legion 7 16achg6 (Hybrid)](lenovo/legion/16achg6/hybrid) | `<nixos-hardware/lenovo/legion/16achg6/hybrid>` |
| [Lenovo Legion 7 16achg6 (Nvidia)](lenovo/legion/16achg6/nvidia) | `<nixos-hardware/lenovo/legion/16achg6/nvidia>` |
| [Lenovo Legion 7i Pro 16irx8h (Intel)](lenovo/legion/16irx8h) | `<nixos-hardware/lenovo/legion/16irx8h>` |
| [Lenovo Legion Y530 15ICH](lenovo/legion/15ich) | `<nixos-hardware/lenovo/legion/15ich>` |
| [Lenovo ThinkPad E14 (AMD)](lenovo/thinkpad/e14/amd) | `<nixos-hardware/lenovo/thinkpad/e14/amd>` |
Expand Down
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
lenovo-legion-16ach6h = import ./lenovo/legion/16ach6h;
lenovo-legion-16ach6h-hybrid = import ./lenovo/legion/16ach6h/hybrid;
lenovo-legion-16ach6h-nvidia = import ./lenovo/legion/16ach6h/nvidia;
lenovo-legion-16achg6-hybrid = import ./lenovo/legion/16achg6/hybrid;
lenovo-legion-16achg6-nvidia = import ./lenovo/legion/16achg6/nvidia;
lenovo-legion-16ithg6 = import ./lenovo/legion/16ithg6;
lenovo-legion-16irx8h = import ./lenovo/legion/16irx8h;
lenovo-legion-y530-15ich = import ./lenovo/legion/15ich;
Expand Down
21 changes: 21 additions & 0 deletions lenovo/legion/16achg6/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
I personally use my laptop with an external display attached. In `hybrid` config it works nice only with Wayland, while X11 can't detect the external monitor. Everything works as expected in `nvidia` mode, but battery life is reduced then.

## Setup at the time of testing
```
$ nix-info -m
- system: `"x86_64-linux"`
- host os: `Linux 6.1.62, NixOS, 23.05 (Stoat), 23.05.20231116.9fb1225`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.13.6`
- channels(beko): `"home-manager-23.05.tar.gz"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
```
```
$ lspci
...
01:00.0 VGA compatible controller: NVIDIA Corporation GA104M [GeForce RTX 3070 Mobile / Max-Q] (rev a1)
...
05:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] (rev c5)
...
```
26 changes: 26 additions & 0 deletions lenovo/legion/16achg6/hybrid/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{ lib, config, ... }:

{
imports = [
../../../../common/cpu/amd
../../../../common/cpu/amd/pstate.nix
../../../../common/gpu/amd
../../../../common/gpu/nvidia/prime.nix
../../../../common/pc/laptop
../../../../common/pc/laptop/ssd
];

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

hardware = {
nvidia = {
modesetting.enable = lib.mkDefault true;
powerManagement.enable = lib.mkDefault true;

prime = {
amdgpuBusId = "PCI:5:0:0";
nvidiaBusId = "PCI:1:0:0";
};
};
};
}
13 changes: 13 additions & 0 deletions lenovo/legion/16achg6/nvidia/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ ... }:

{
imports = [ ../hybrid ];
services.xserver.videoDrivers = [ "nvidia" ];
hardware = {
nvidia.prime.offload.enable = false;
amdgpu = {
amdvlk = false;
opencl = false;
};
};
}

1 comment on commit 7763c6f

@nixos-discourse
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/what-else-can-i-try-to-make-my-optimus-nvidia-card-work-well-with-x11/36958/1

Please sign in to comment.