Skip to content

Commit e1c4bac

Browse files
Mic92mergify[bot]
authored andcommitted
Lenovo ThinkPad Z13 Gen 2 (NixOS#844)
lenovo-thinkpad-z: remove HiDPI * lenovo-thinkpad-z: move z13 to gen1/z13, leave generic settings * lenovo-thinkpad-z-gen2: add z13 * Update lenovo/thinkpad/z/gen2/default.nix * Update lenovo/thinkpad/z/gen2/default.nix
1 parent 79a20e2 commit e1c4bac

File tree

9 files changed

+91
-11
lines changed

9 files changed

+91
-11
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ See code for all available configurations.
238238
| [Lenovo ThinkPad X280](lenovo/thinkpad/x280) | `<nixos-hardware/lenovo/thinkpad/x280>` |
239239
| [Lenovo ThinkPad X390](lenovo/thinkpad/x390) | `<nixos-hardware/lenovo/thinkpad/x390>` |
240240
| [Lenovo ThinkPad Z Series](lenovo/thinkpad/z) | `<nixos-hardware/lenovo/thinkpad/z>` |
241-
| [Lenovo ThinkPad Z13](lenovo/thinkpad/z/z13) | `<nixos-hardware/lenovo/thinkpad/z/z13>` |
241+
| [Lenovo ThinkPad Z13 Gen 1](lenovo/thinkpad/z/gen1/z13) | `<nixos-hardware/lenovo/thinkpad/z/gen1/z13>` |
242+
| [Lenovo ThinkPad Z13 Gen 2](lenovo/thinkpad/z/gen2/z13) | `<nixos-hardware/lenovo/thinkpad/z/gen2/z13>` |
242243
| [LENOVO Yoga 6 13ALC6 82ND](lenovo/yoga/6/13ALC6) | `<nixos-hardware/lenovo/yoga/6/13ALC6>` |
243244
| [LENOVO Yoga Slim 7 Pro-X 14ARH7 82ND](lenovo/yoga/7/14ARH7/amdgpu) | `<nixos-hardware/lenovo/yoga/7/14ARH7/amdgpu>` |
244245
| [LENOVO Yoga Slim 7 Pro-X 14ARH7 82ND](lenovo/yoga/7/14ARH7/nvidia) | `<nixos-hardware/lenovo/yoga/7/14ARH7/nvidia>` |

flake.nix

+2-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@
175175
lenovo-thinkpad-x280 = import ./lenovo/thinkpad/x280;
176176
lenovo-thinkpad-x390 = import ./lenovo/thinkpad/x390;
177177
lenovo-thinkpad-z = import ./lenovo/thinkpad/z;
178-
lenovo-thinkpad-z13 = import ./lenovo/thinkpad/z/z13;
178+
lenovo-thinkpad-z13-gen1 = import ./lenovo/thinkpad/z/gen1/z13;
179+
lenovo-thinkpad-z13-gen2 = import ./lenovo/thinkpad/z/gen2/z13;
179180
lenovo-yoga-6-13ALC6 = import ./lenovo/yoga/6/13ALC6;
180181
lenovo-yoga-7-14ARH7 = import ./lenovo/yoga/7/14ARH7;
181182
lenovo-yoga-7-slim-gen8 = import ./lenovo/yoga/7/slim/gen8;

lenovo/thinkpad/z/default.nix

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@
77
../../../common/pc/laptop
88
../../../common/pc/laptop/acpi_call.nix
99
../../../common/pc/laptop/ssd
10-
../../../common/hidpi.nix # can be dropped after nixos 23.05
1110
];
12-
# kernel versions prior to 5.18 won't boot
13-
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.18") (lib.mkDefault pkgs.linuxPackages_latest);
1411

1512
hardware.enableRedistributableFirmware = lib.mkDefault true;
1613
hardware.trackpoint.device = lib.mkDefault "TPPS/2 Elan TrackPoint";
1714

1815
services.fprintd.enable = lib.mkDefault true;
1916

20-
# kernel versions below 6.0 don't contain ACPI suspend2idle drivers for the Z13s AMD hardware
17+
# kernel versions below 6.0 dont contain ACPI suspend2idle drivers for the Z-series’ AMD hardware
2118
# my Z13 froze after waking up from suspend/ hibernate
2219
services.logind.lidSwitch = lib.mkIf (lib.versionOlder pkgs.linux.version "6.00") (lib.mkDefault "lock");
2320
}

lenovo/thinkpad/z/gen1/default.nix

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{ lib, pkgs, ... }: {
2+
imports = [
3+
../../../../lenovo/thinkpad/z
4+
];
5+
6+
# Kernel 5.18 is required for the Ryzen 6000 series
7+
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.18") (lib.mkDefault pkgs.linuxPackages_latest);
8+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
imports = [
3+
../../../../../lenovo/thinkpad/z/gen1
4+
];
5+
}

lenovo/thinkpad/z/gen2/default.nix

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{ lib, pkgs, ... }:
2+
3+
{
4+
imports = [
5+
../../../../lenovo/thinkpad/z
6+
];
7+
8+
# Kernel 6.4 is required for the Ryzen 7040 series
9+
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "6.4") (lib.mkDefault pkgs.linuxPackages_latest);
10+
11+
systemd.services = {
12+
# Modified from Arch Wiki
13+
"touchpad-fix" = {
14+
enable = lib.mkDefault true;
15+
description = "I2C HID devices can fail to initialize so try to reload";
16+
unitConfig = {
17+
Type = "oneshot";
18+
};
19+
serviceConfig = {
20+
User = "root";
21+
};
22+
wantedBy = [ "multi-user.target" ];
23+
after = [ "multi-user.target" ];
24+
script = ''
25+
count=0
26+
while true; do
27+
${lib.getExe pkgs.libinput} list-devices | ${lib.getExe pkgs.gnugrep} --quiet SNSL && break
28+
count=$((count + 1))
29+
30+
if test $count -ge 5; then
31+
echo "Touchpad not read after $count attempts"
32+
break
33+
fi
34+
35+
echo "Touchpad not ready; attempt $count to reload"
36+
${pkgs.kmod}/bin/rmmod i2c_hid_acpi
37+
${pkgs.kmod}/bin/modprobe i2c_hid_acpi
38+
39+
sleep $((2 + (count * 3)))
40+
done
41+
'';
42+
};
43+
};
44+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{ pkgs, lib, ...}:
2+
3+
{
4+
imports = [
5+
../../../../../lenovo/thinkpad/z/gen2
6+
];
7+
8+
sound.extraConfig = ''
9+
pcm.!default {
10+
type plug
11+
slave.pcm "hw:1,0"
12+
}
13+
14+
ctl.!default {
15+
type hw
16+
card 1
17+
}
18+
'';
19+
}

lenovo/thinkpad/z/z13/default.nix

-5
This file was deleted.

lenovo/thinkpad/z13/default.nix

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
assertions = [
3+
{
4+
assertion = true;
5+
message = ''
6+
Lenovo Z-series received a second generation so the hardware configuration has been split by generation. For the Z13 Gen 1 config, change from `lenovo-thinkpad-z13` to `lenovo-thinkpad-z13-gen1`.
7+
'';
8+
}
9+
];
10+
}

0 commit comments

Comments
 (0)