mirror of
				https://github.com/NixOS/nixos-hardware.git
				synced 2025-11-04 09:17:14 +08:00 
			
		
		
		
	Lenovo ThinkPad Z13 Gen 2 (#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
This commit is contained in:
		@@ -7,17 +7,14 @@
 | 
			
		||||
    ../../../common/pc/laptop
 | 
			
		||||
    ../../../common/pc/laptop/acpi_call.nix
 | 
			
		||||
    ../../../common/pc/laptop/ssd
 | 
			
		||||
    ../../../common/hidpi.nix # can be dropped after nixos 23.05
 | 
			
		||||
  ];
 | 
			
		||||
  # kernel versions prior to 5.18 won't boot
 | 
			
		||||
  boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.18") (lib.mkDefault pkgs.linuxPackages_latest);
 | 
			
		||||
 | 
			
		||||
  hardware.enableRedistributableFirmware = lib.mkDefault true;
 | 
			
		||||
  hardware.trackpoint.device = lib.mkDefault "TPPS/2 Elan TrackPoint";
 | 
			
		||||
 | 
			
		||||
  services.fprintd.enable = lib.mkDefault true;
 | 
			
		||||
 | 
			
		||||
  # kernel versions below 6.0 don't contain ACPI suspend2idle drivers for the Z13s AMD hardware
 | 
			
		||||
  # kernel versions below 6.0 don’t contain ACPI suspend2idle drivers for the Z-series’ AMD hardware
 | 
			
		||||
  # my Z13 froze after waking up from suspend/ hibernate
 | 
			
		||||
  services.logind.lidSwitch = lib.mkIf (lib.versionOlder pkgs.linux.version "6.00") (lib.mkDefault "lock");
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								lenovo/thinkpad/z/gen1/default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lenovo/thinkpad/z/gen1/default.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
{ lib, pkgs, ... }: {
 | 
			
		||||
  imports = [
 | 
			
		||||
    ../../../../lenovo/thinkpad/z
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  # Kernel 5.18 is required for the Ryzen 6000 series
 | 
			
		||||
  boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.18") (lib.mkDefault pkgs.linuxPackages_latest);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										5
									
								
								lenovo/thinkpad/z/gen1/z13/default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								lenovo/thinkpad/z/gen1/z13/default.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
{
 | 
			
		||||
  imports = [
 | 
			
		||||
    ../../../../../lenovo/thinkpad/z/gen1
 | 
			
		||||
  ];
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										44
									
								
								lenovo/thinkpad/z/gen2/default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								lenovo/thinkpad/z/gen2/default.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
{ lib, pkgs, ... }:
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  imports = [
 | 
			
		||||
    ../../../../lenovo/thinkpad/z
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  # Kernel 6.4 is required for the Ryzen 7040 series
 | 
			
		||||
  boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "6.4") (lib.mkDefault pkgs.linuxPackages_latest);
 | 
			
		||||
 | 
			
		||||
  systemd.services = {
 | 
			
		||||
    # Modified from Arch Wiki
 | 
			
		||||
    "touchpad-fix" = {
 | 
			
		||||
      enable = lib.mkDefault true;
 | 
			
		||||
      description = "I2C HID devices can fail to initialize so try to reload";
 | 
			
		||||
      unitConfig = {
 | 
			
		||||
        Type = "oneshot";
 | 
			
		||||
      };
 | 
			
		||||
      serviceConfig = {
 | 
			
		||||
        User = "root";
 | 
			
		||||
      };
 | 
			
		||||
      wantedBy = [ "multi-user.target" ];
 | 
			
		||||
      after = [ "multi-user.target" ];
 | 
			
		||||
      script = ''
 | 
			
		||||
        count=0
 | 
			
		||||
        while true; do
 | 
			
		||||
            ${lib.getExe pkgs.libinput} list-devices | ${lib.getExe pkgs.gnugrep} --quiet SNSL && break
 | 
			
		||||
            count=$((count + 1))
 | 
			
		||||
 | 
			
		||||
            if test $count -ge 5; then
 | 
			
		||||
                echo "Touchpad not read after $count attempts"
 | 
			
		||||
                break
 | 
			
		||||
            fi
 | 
			
		||||
 | 
			
		||||
            echo "Touchpad not ready; attempt $count to reload"
 | 
			
		||||
            ${pkgs.kmod}/bin/rmmod i2c_hid_acpi
 | 
			
		||||
            ${pkgs.kmod}/bin/modprobe i2c_hid_acpi
 | 
			
		||||
 | 
			
		||||
            sleep $((2 + (count * 3)))
 | 
			
		||||
        done
 | 
			
		||||
      '';
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								lenovo/thinkpad/z/gen2/z13/default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								lenovo/thinkpad/z/gen2/z13/default.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
{ pkgs, lib, ...}:
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  imports = [
 | 
			
		||||
    ../../../../../lenovo/thinkpad/z/gen2
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  sound.extraConfig = ''
 | 
			
		||||
    pcm.!default {
 | 
			
		||||
        type plug
 | 
			
		||||
        slave.pcm "hw:1,0"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ctl.!default {
 | 
			
		||||
        type hw
 | 
			
		||||
        card 1
 | 
			
		||||
    }
 | 
			
		||||
  '';
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  imports = [
 | 
			
		||||
    ../../../../lenovo/thinkpad/z
 | 
			
		||||
  ];
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										10
									
								
								lenovo/thinkpad/z13/default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								lenovo/thinkpad/z13/default.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
{
 | 
			
		||||
  assertions = [
 | 
			
		||||
    {
 | 
			
		||||
      assertion = true;
 | 
			
		||||
      message = ''
 | 
			
		||||
        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`.
 | 
			
		||||
      '';
 | 
			
		||||
    }
 | 
			
		||||
  ];
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user