NixOS on ThinkPad X13s: minimal configuration

{ config, lib, pkgs, ... }:

let
  linux_x13s_pkg = { buildLinux, ... } @ args:
    buildLinux (args // rec {
      version = "6.2.0";
      modDirVersion = "6.2.0-rc6";

      src = pkgs.fetchurl {
        url = "https://github.com/jhovold/linux/archive/refs/heads/wip/sc8280xp-v6.2-rc6.tar.gz";
        sha256 = "sha256-nBxe/bWQ9IzqmDsGb2Q73jthFD69LUFKarwmYp2hviM=";
      };
      kernelPatches = [];

      extraMeta.branch = "6.2";
    } // (args.argsOverride or { }));

  linux_x13s = pkgs.callPackage linux_x13s_pkg {
    defconfig = "johan_defconfig";
  };

  linuxPackages_x13s = pkgs.linuxPackagesFor linux_x13s;
in {
  imports = [ ./hardware-configuration.nix ];

  boot = {
    loader.systemd-boot.enable = true;
    kernelPackages = linuxPackages_x13s;
    kernelParams = [
      "clk_ignore_unused"
      "pd_ignore_unused"
      "arm64.nopauth"
      "cma=128M"
      "dtb=x13s.dtb"
    ];
    initrd = {
      includeDefaultModules = false;
      availableKernelModules = [
        "i2c-core"
        "i2c-hid"
        "i2c-hid-of"
        "i2c-qcom-geni"
        "pcie-qcom"
        "phy-qcom-qmp-combo"
        "phy-qcom-qmp-pcie"
        "phy-qcom-qmp-usb"
        "phy-qcom-snps-femto-v2"
        "phy-qcom-usb-hs"
      ];
    };
  };

  networking.networkmanager.enable = true;
}

After nixos-install

cp $(find /nix/store | grep sc8280xp-lenovo-thinkpad-x13s.dtb) /boot/x13s.dtb