diff --git a/README.md b/README.md index 120b781..1d73f7a 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,8 @@ See code for all available configurations. | [Lenovo Legion 5 15arh05h](lenovo/legion/15arh05h) | `` | | [Lenovo Legion 7 Slim 15ach6](lenovo/legion/15ach6) | `` | | [Lenovo Legion 5 Pro 16ach6h](lenovo/legion/16ach6h) | `` | +| [Lenovo Legion 5 Pro 16ach6h (Hybrid)](lenovo/legion/16ach6h/hybrid)| `` | +| [Lenovo Legion 5 Pro 16ach6h (Nvidia)](lenovo/legion/16ach6h/nvidia)| `` | | [Lenovo ThinkPad E14 (AMD)](lenovo/thinkpad/e14/amd) | `` | | [Lenovo ThinkPad E14 (Intel)](lenovo/thinkpad/e14/intel) | `` | | [Lenovo ThinkPad E470](lenovo/thinkpad/e470) | `` | diff --git a/flake.nix b/flake.nix index 64d1351..5b79eca 100644 --- a/flake.nix +++ b/flake.nix @@ -63,6 +63,8 @@ lenovo-legion-15ach6 = import ./lenovo/legion/15ach6; lenovo-legion-15arh05h = import ./lenovo/legion/15arh05h; 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-16ithg6 = import ./lenovo/legion/16ithg6; lenovo-thinkpad = import ./lenovo/thinkpad; lenovo-thinkpad-e14-amd = import ./lenovo/thinkpad/e14/amd; diff --git a/lenovo/legion/16ach6h/README.md b/lenovo/legion/16ach6h/README.md index cf489fa..f8c1190 100644 --- a/lenovo/legion/16ach6h/README.md +++ b/lenovo/legion/16ach6h/README.md @@ -1,3 +1,8 @@ +## Introduction +Due to the introduction of DDG feature, you may toggle DDG frequently, so for the default settings of this laptop, we use "specialization" feature of Nix so that you can easily select the required graphics card driver in the startup menu. +**But It will slow down NixOS evaluation by factor 2 and increase memory usage.** +So if you don't need specialization feature, you can just use hybrid only configuration or nvidia only (DDG only) configuration + ## Setup at the time of testing ``` $ nix-info -m diff --git a/lenovo/legion/16ach6h/default.nix b/lenovo/legion/16ach6h/default.nix index db13b9f..e893231 100644 --- a/lenovo/legion/16ach6h/default.nix +++ b/lenovo/legion/16ach6h/default.nix @@ -1,18 +1,11 @@ -{ lib, ... }: +{ ... }: { - imports = [ - ../../../common/cpu/amd - ../../../common/gpu/amd - ../../../common/gpu/nvidia/prime.nix - ../../../common/pc/laptop - ../../../common/pc/laptop/ssd - ]; + imports = [ ./hybrid ]; - hardware.nvidia.prime = { - amdgpuBusId = "PCI:6:0:0"; - nvidiaBusId = "PCI:1:0:0"; + specialisation.ddg.configuration = { + # This specialisation is for the case where "DDG" (A hardware feature that can enable in bios) is enabled, since the amd igpu is blocked at hardware level and the built-in display is directly connected to the dgpu, we no longer need the amdgpu and prime configuration. + services.xserver.videoDrivers = [ "nvidia" ]; # This will override services.xserver.videoDrivers = lib.mkDefault [ "amdgpu" "nvidia" ]; + hardware.nvidia.prime.offload.enable = false; }; - - services.thermald.enable = lib.mkDefault true; -} +} \ No newline at end of file diff --git a/lenovo/legion/16ach6h/edid/16ach6h.bin b/lenovo/legion/16ach6h/edid/16ach6h.bin new file mode 100644 index 0000000..8725613 Binary files /dev/null and b/lenovo/legion/16ach6h/edid/16ach6h.bin differ diff --git a/lenovo/legion/16ach6h/edid/default.nix b/lenovo/legion/16ach6h/edid/default.nix new file mode 100644 index 0000000..d9d8b52 --- /dev/null +++ b/lenovo/legion/16ach6h/edid/default.nix @@ -0,0 +1,15 @@ +{ config, pkgs, lib, ...}: + +let + # This file was obtained from the display while "DDG" mode was enabled. + chip_edid = pkgs.runCommandNoCC "chip_edid" { } '' + mkdir -p $out/lib/firmware/edid + cp ${./16ach6h.bin} $out/lib/firmware/edid/16ach6h.bin + ''; +in +{ + hardware.firmware = [ chip_edid ]; + + boot.kernelParams = [ "drm.edid_firmware=edid/16ach6h.bin" ]; + boot.initrd.extraFiles."lib/firmware/edid/16ach6h.bin".source = pkgs.runCommandLocal "chip_edid" { } "cp ${./16ach6h.bin} $out"; +} \ No newline at end of file diff --git a/lenovo/legion/16ach6h/hybrid/default.nix b/lenovo/legion/16ach6h/hybrid/default.nix new file mode 100644 index 0000000..8a56a48 --- /dev/null +++ b/lenovo/legion/16ach6h/hybrid/default.nix @@ -0,0 +1,28 @@ +{ config, lib, ... }: + +{ + imports = [ + ../../../../common/cpu/amd + ../../../../common/gpu/amd + ../../../../common/gpu/nvidia/prime.nix + ../../../../common/pc/laptop + ../../../../common/pc/laptop/ssd + ../edid + ]; + + hardware = { + amdgpu.loadInInitrd = lib.mkDefault false; + + nvidia = { + modesetting.enable = lib.mkDefault true; + powerManagement.enable = lib.mkDefault true; + + prime = { + amdgpuBusId = "PCI:6:0:0"; + nvidiaBusId = "PCI:1:0:0"; + }; + }; + }; + + services.thermald.enable = lib.mkDefault true; +} \ No newline at end of file diff --git a/lenovo/legion/16ach6h/nvidia/default.nix b/lenovo/legion/16ach6h/nvidia/default.nix new file mode 100644 index 0000000..e54fc20 --- /dev/null +++ b/lenovo/legion/16ach6h/nvidia/default.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + imports = [ ../hybrid ]; + services.xserver.videoDrivers = [ "nvidia" ]; # This will override services.xserver.videoDrivers = lib.mkDefault [ "amdgpu" "nvidia" ]; + hardware.nvidia.prime.offload.enable = false; +} \ No newline at end of file