apple/t2: pin kernel releases; upgrade version and patches

disconnect kernel versions from nixpkgs, which should avoid breaking users'
config when nixpkgs has a new version and some patches are incompatible,
and when a PR updating the patches are still waiting to be merged, like
in #2027.

Signed-off-by: Sophie Cheung <git@soopy.moe>
This commit is contained in:
Sophie Cheung committed 2026-10-07 20:05:18 +08:00
1 parent 06f9ecaea5
commit 701eb9f269
6 files changed
+125 -57

No files matched your search

+2 -5
View File
@@ -1,6 +1,3 @@
{ callPackage, linux_6_18, ... }@args: { callPackage, ... }@args:
callPackage ./generic.nix args { callPackage ./generic.nix args ./stable.json
kernel = linux_6_18;
patchesFile = ./stable.json;
}
+19 -9
View File
@@ -1,13 +1,13 @@
{ {
lib, lib,
fetchurl, # fetchpatch does unnecessary normalization fetchurl, # fetchpatch does unnecessary normalization
buildLinux,
linuxKernel,
... ...
}@args: }@args:
{ patchesFile:
kernel,
patchesFile,
}:
let let
inherit (builtins) readFile fromJSON; inherit (builtins) readFile fromJSON;
@@ -23,10 +23,14 @@ let
} }
) patchset.patches; ) patchset.patches;
in in
kernel.override ( buildLinux (
args {
// {
pname = "linux-t2"; pname = "linux-t2";
version = patchset.kernel.version;
src = fetchurl {
inherit (patchset.kernel) url hash;
};
structuredExtraConfig = with lib.kernel; { structuredExtraConfig = with lib.kernel; {
APPLE_BCE = module; APPLE_BCE = module;
@@ -47,9 +51,15 @@ kernel.override (
STAGING = yes; STAGING = yes;
}; };
kernelPatches = t2-patches ++ (args.kernelPatches or [ ]); kernelPatches = [
# include default patches for good measure
linuxKernel.kernelPatches.request_key_helper
linuxKernel.kernelPatches.bridge_stp_helper
]
++ t2-patches
++ (args.kernelPatches or [ ]);
argsOverride.extraMeta = { extraMeta = {
description = "The Linux kernel (with patches from the T2 Linux project)"; description = "The Linux kernel (with patches from the T2 Linux project)";
# take responsibility for the downstream kernel # take responsibility for the downstream kernel
+41 -16
View File
@@ -1,25 +1,30 @@
{ {
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/7ee7d19c38e5df31a386b2a0c35ca8f064003960/", "base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/65fdd4d492d7e219a05742ce4768f16e5ba4f976/",
"kernel": {
"version": "7.2.9",
"url": "mirror://kernel/linux/kernel/v7.x/linux-7.2.9.tar.xz",
"hash": "sha256:1fnqp28vrikz9gqhb42k0dsggqf8i07j0s9qy33scr53a6zdzidl"
},
"patches": [ "patches": [
{ {
"name": "1001-Add-apple-bce-driver.patch", "name": "1001-Add-t2bce-driver-stack.patch",
"hash": "sha256-v/P3Ws3x+OPnmX3vSFLxARON0HNjjDRe7QJ+KP9tVsc=" "hash": "sha256-QeAffMClzGsGdHC5Qce744X2WUcx6PI0CJ5BQ8txxQ8="
}, },
{ {
"name": "1002-Put-apple-bce-in-drivers-staging.patch", "name": "1002-Integrate-t2bce-driver-stack.patch",
"hash": "sha256-rK1lQ3fjHJH//50n37xgWrUs4CZ8lmFw0iDpbq5zoaY=" "hash": "sha256-nPAPGV9IROyxSQzSztwNS1fY0ziGQJ7evKBs1ZSHwiE="
}, },
{ {
"name": "2008-i915-4-lane-quirk-for-mbp15-1.patch", "name": "2008-i915-4-lane-quirk-for-mbp15-1.patch",
"hash": "sha256-S2osR1aSjqJiO7rNZP1sKt2+Uxyitwse/6BXMJvE9as=" "hash": "sha256-gTYP7WHV/Qulobdi1nNdYsv1CWgkM8pGvsCFQ+rvhrw="
}, },
{ {
"name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch", "name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch",
"hash": "sha256-6i+fh/Ifle0di5/tMOdMm0NMkEmeUb17hYM/g2j2dfI=" "hash": "sha256-OczfcYSvkw2lBZQzZjCV4LHSe6CnaJ1J8GBkgEbiOXk="
}, },
{ {
"name": "3001-applesmc-convert-static-structures-to-drvdata.patch", "name": "3001-applesmc-convert-static-structures-to-drvdata.patch",
"hash": "sha256-7KGC0pCos351wKNhwJI/Qoc7w+orOPpiTkdCN50G8nI=" "hash": "sha256-FVtOCXInI5OUqpTVDVsZ1taMwj3z+d3PeRgjnQQljG4="
}, },
{ {
"name": "3002-applesmc-make-io-port-base-addr-dynamic.patch", "name": "3002-applesmc-make-io-port-base-addr-dynamic.patch",
@@ -55,35 +60,55 @@
}, },
{ {
"name": "4001-asahi-trackpad.patch", "name": "4001-asahi-trackpad.patch",
"hash": "sha256-ANHSNoy5nK2b+rSAG0bJ8j6ZBmNqgeCddHXVS31KyDw=" "hash": "sha256-RuYI0t+rMu29wSkVT4suYJgGzS1ZruN/HBZWkLivlDw="
}, },
{ {
"name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch", "name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch",
"hash": "sha256-T2tYcFLeWUdx6QawANe3ZNVSRxmo1IdPiSpGLQk4IDY=" "hash": "sha256-LLZzcysLTuQrSXWXbdq7AASxfMInQoqpWzRNZAKws9k="
}, },
{ {
"name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch", "name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch",
"hash": "sha256-ubchCEv1BZ7t/zkI9DpHA4gUln9cdu4yHzVJI2TNlS0=" "hash": "sha256-kUnbtl/54cihscirl9kP0Gsot7bdP0rYKlj6gQ10hk0="
},
{
"name": "4005-HID-magicmouse-fix-regression-breaking-support-for-M.patch",
"hash": "sha256-oT+3AeETnKfzblxtcTD18c61BKoD9yAsga0AL3R8u7k="
}, },
{ {
"name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch", "name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch",
"hash": "sha256-KV5DTjALzNugs92Jum6VUt0wgblK/6PG1KorovHcIX0=" "hash": "sha256-KV5DTjALzNugs92Jum6VUt0wgblK/6PG1KorovHcIX0="
}, },
{
"name": "5002-drm-appletbdrm-Add-suspend-and-resume-support.patch",
"hash": "sha256-NFa5ZpNguUC9ELfphvCrVHEh59tN/ZA9vQl6YD1avbI="
},
{
"name": "6001-drm-amd-pm-Fix-boot-problems-in-5300.patch",
"hash": "sha256-l6pyVkpumURgoQ/f1kGfw47YhMuuMjpiHgjP6QN8dNE="
},
{ {
"name": "7001-drm-i915-fbdev-Discard-BIOS-framebuffers-exceeding-h.patch", "name": "7001-drm-i915-fbdev-Discard-BIOS-framebuffers-exceeding-h.patch",
"hash": "sha256-/EKN7JsAxcpAgfJFtPp2NLYaGqQ0kl8wjJEXifSzJpY=" "hash": "sha256-/EKN7JsAxcpAgfJFtPp2NLYaGqQ0kl8wjJEXifSzJpY="
}, },
{
"name": "7002-drm-amdgpu-reset-VI-ASIC-on-MacBookPro15-1.patch",
"hash": "sha256-lLruG4lJAI6fI94w2LzHmrbspXArrq+rbI/SJmhwXqo="
},
{
"name": "7003-amdgpu-add-support-for-5K.patch",
"hash": "sha256-RX3tiju4gNFlrrYWOMdUr0HAdSN5RliliiPAQw5I6/M="
},
{ {
"name": "8001-Add-APFS-driver.patch", "name": "8001-Add-APFS-driver.patch",
"hash": "sha256-EbIbfkncp5Jax2suny/jlFt+cD9MyYMV2rWFJIbgbg4=" "hash": "sha256-DU/jX8wuM6Y/5iZztg05GjWlzVlo8DfVpCJ3BxFoTJo="
}, },
{ {
"name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch", "name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch",
"hash": "sha256-zCTetF2NPhMH2BknPumhPz2sf26X9Lcra7xCA3R2WMY=" "hash": "sha256-zCTetF2NPhMH2BknPumhPz2sf26X9Lcra7xCA3R2WMY="
},
{
"name": "9001-ACPI-x86-Apple-T2-systems-need-early-CPU-offlining.patch",
"hash": "sha256-camFPvnBQMErjVrbsdPPfsbyy59w0e0iPkVR1Juzv8o="
},
{
"name": "9002-Bluetooth-hci_event-strip-Broadcom-vendor-bits-from-adv-type.patch",
"hash": "sha256-oikMBjD4gyqTs351q7nTz6lI6rJqOe1/LfxpHAieEOs="
} }
] ]
} }
+2 -5
View File
@@ -1,6 +1,3 @@
{ callPackage, linux_7_0, ... }@args: { callPackage, ... }@args:
callPackage ./generic.nix args { callPackage ./generic.nix args ./latest.json
kernel = linux_7_0;
patchesFile = ./latest.json;
}
+28 -15
View File
@@ -1,17 +1,26 @@
{ {
"base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/facf1c778667c3ef62104949ef64c75ce7e43b0a/", "base_url": "https://raw.githubusercontent.com/t2linux/linux-t2-patches/2eed0f6c812e8f36cb7a7f7bcde69f6f87074bdf/",
"kernel": {
"version": "6.18.55",
"url": "mirror://kernel/linux/kernel/v6.x/linux-6.18.55.tar.xz",
"hash": "sha256:1yadaa2gz74nh3pawpwv6lamalnd7wpiv1xb88pw2rd1c606647l"
},
"patches": [ "patches": [
{ {
"name": "1001-Add-apple-bce-driver.patch", "name": "1001-Add-t2bce-driver-stack.patch",
"hash": "sha256-rrL3oVkYeq5ZslnjCQw4hcEK6knsm6U/wp1XnJmQTSA=" "hash": "sha256-OG4Y7cN75pHWF7huV+2Fqtq0ik2aITMWtF43mD+RFCU="
}, },
{ {
"name": "1002-Put-apple-bce-in-drivers-staging.patch", "name": "1002-Integrate-t2bce-driver-stack.patch",
"hash": "sha256-deWROYcncl51sOmtvUHM61e5FM1beHbOJVp4iI31LHM=" "hash": "sha256-z3g3IOAL+Nze88oKDSYpLHVtFnhz2kP1Udap5J64WmM="
},
{
"name": "1003-Fix-for-6.18.patch",
"hash": "sha256-ozJkJFm11oGDW1Gwrp4AR4Ifv9X8Yix6uF9ZBFJ76+M="
}, },
{ {
"name": "2008-i915-4-lane-quirk-for-mbp15-1.patch", "name": "2008-i915-4-lane-quirk-for-mbp15-1.patch",
"hash": "sha256-S2osR1aSjqJiO7rNZP1sKt2+Uxyitwse/6BXMJvE9as=" "hash": "sha256-gTYP7WHV/Qulobdi1nNdYsv1CWgkM8pGvsCFQ+rvhrw="
}, },
{ {
"name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch", "name": "2009-apple-gmux-allow-switching-to-igpu-at-probe.patch",
@@ -19,7 +28,7 @@
}, },
{ {
"name": "3001-applesmc-convert-static-structures-to-drvdata.patch", "name": "3001-applesmc-convert-static-structures-to-drvdata.patch",
"hash": "sha256-7KGC0pCos351wKNhwJI/Qoc7w+orOPpiTkdCN50G8nI=" "hash": "sha256-c/d+c5eKzhbtfUKtLC7AB+6vMXge4ZzPJAUbNENWH7g="
}, },
{ {
"name": "3002-applesmc-make-io-port-base-addr-dynamic.patch", "name": "3002-applesmc-make-io-port-base-addr-dynamic.patch",
@@ -55,31 +64,35 @@
}, },
{ {
"name": "4001-asahi-trackpad.patch", "name": "4001-asahi-trackpad.patch",
"hash": "sha256-+YXyIjtlVrLo8allTO3M1A+xold5FUXaZ8dwD2j5HDc=" "hash": "sha256-2h3TdPsX9HBXx5jkZ2S2GJkjFcdL8vKD1G69iqd9IWg="
}, },
{ {
"name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch", "name": "4003-HID-apple-ignore-the-trackpad-on-T2-Macs.patch",
"hash": "sha256-T2tYcFLeWUdx6QawANe3ZNVSRxmo1IdPiSpGLQk4IDY=" "hash": "sha256-LLZzcysLTuQrSXWXbdq7AASxfMInQoqpWzRNZAKws9k="
}, },
{ {
"name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch", "name": "4004-HID-magicmouse-Add-support-for-trackpads-found-on-T2.patch",
"hash": "sha256-ubchCEv1BZ7t/zkI9DpHA4gUln9cdu4yHzVJI2TNlS0=" "hash": "sha256-kUnbtl/54cihscirl9kP0Gsot7bdP0rYKlj6gQ10hk0="
},
{
"name": "4005-HID-magicmouse-fix-regression-breaking-support-for-M.patch",
"hash": "sha256-oT+3AeETnKfzblxtcTD18c61BKoD9yAsga0AL3R8u7k="
}, },
{ {
"name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch", "name": "5001-HID-appletb-kbd-add-option-to-switch-default-layer-o.patch",
"hash": "sha256-KV5DTjALzNugs92Jum6VUt0wgblK/6PG1KorovHcIX0=" "hash": "sha256-KV5DTjALzNugs92Jum6VUt0wgblK/6PG1KorovHcIX0="
}, },
{
"name": "5002-drm-appletbdrm-Add-suspend-and-resume-support.patch",
"hash": "sha256-NFa5ZpNguUC9ELfphvCrVHEh59tN/ZA9vQl6YD1avbI="
},
{ {
"name": "7001-drm-i915-fbdev-Discard-BIOS-framebuffers-exceeding-h.patch", "name": "7001-drm-i915-fbdev-Discard-BIOS-framebuffers-exceeding-h.patch",
"hash": "sha256-/EKN7JsAxcpAgfJFtPp2NLYaGqQ0kl8wjJEXifSzJpY=" "hash": "sha256-/EKN7JsAxcpAgfJFtPp2NLYaGqQ0kl8wjJEXifSzJpY="
}, },
{
"name": "7002-drm-amdgpu-reset-VI-ASIC-on-MacBookPro15-1.patch",
"hash": "sha256-lLruG4lJAI6fI94w2LzHmrbspXArrq+rbI/SJmhwXqo="
},
{ {
"name": "8001-Add-APFS-driver.patch", "name": "8001-Add-APFS-driver.patch",
"hash": "sha256-2By3Zlg/i5rUUJDlWc6JoiqapUnbVplk2lHzDhvAhzI=" "hash": "sha256-fL9TftzTd5PurxIDrzaPsysGExrMySGOsm6H8NFd7JY="
}, },
{ {
"name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch", "name": "8002-Necessary-modifications-to-build-APFS-with-the-kerne.patch",
+33 -7
View File
@@ -15,21 +15,26 @@ API_BASE = "https://api.github.com"
PATCH_PATTERN = re.compile(r"^\d{4}-.*\.patch$") PATCH_PATTERN = re.compile(r"^\d{4}-.*\.patch$")
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Update linux-t2 patches from a GitHub repository." description="Update linux-t2 patches from a GitHub repository.",
epilog='''
If both --branch and --reference flags are given, the argument of --reference will be used to fetch the Git
revision for patches and --branch as the kernel branch.
If only --branch is given, the argument will be used for both resolving the Git ref and the kernel branch.
''',
) )
parser.add_argument("filename", help="the output filename") parser.add_argument("filename", help="the output filename")
parser.add_argument( parser.add_argument(
"--repository", "--repository",
help="the source github repository", help="the source github repository (default: %(default)s)",
default="t2linux/linux-t2-patches", default="t2linux/linux-t2-patches",
nargs="?", nargs="?",
) )
ref_group = parser.add_mutually_exclusive_group() parser.add_argument(
ref_group.add_argument(
"--reference", help="the git reference for the patches", default=None, nargs="?" "--reference", help="the git reference for the patches", default=None, nargs="?"
) )
ref_group.add_argument( parser.add_argument(
"--branch", help="the git branch to fetch", default=None, nargs="?" "--branch", help="the kernel branch to fetch (default: latest, example: 6.18)", default=None, nargs="?"
) )
@@ -62,6 +67,27 @@ def main():
reference = args.reference reference = args.reference
branch = args.branch branch = args.branch
print("Fetching kernel releases")
releases = requests.get("https://kernel.org/releases.json").json()['releases']
match = None
patched_url = ""
if not branch:
print("Branch not provided, fetching latest non-mainline kernel version")
# if the json schema changes this script would break, hopefully won't happen
match = next(filter(lambda x: x["moniker"] != "mainline", releases), None)
else:
match = next(filter(lambda x: x["version"].startswith(branch), releases), None)
if not match:
print(f"ERROR: could not find a kernel release for branch {branch}.")
return 1
patched_url = match['source'].replace('https://cdn.kernel.org/pub', 'mirror://kernel')
release_hash = subprocess.check_output(["nix-prefetch-url", "--type", "sha256", patched_url]).decode().strip()
print(f" Kernel: {match['version']}")
print(f" URL: {patched_url}")
print(f" Hash: sha256:{release_hash}")
kernel = {"version": match["version"], "url": patched_url, "hash": f"sha256:{release_hash}"}
if reference is None: if reference is None:
if branch is None: if branch is None:
print("Branch and reference not provided, fetching default branch") print("Branch and reference not provided, fetching default branch")
@@ -85,7 +111,7 @@ def main():
for future in as_completed(futures): for future in as_completed(futures):
patches_with_hash.append(future.result()) patches_with_hash.append(future.result())
result = {"base_url": base_url, "patches": sorted(patches_with_hash, key=lambda p: p["name"])} result = {"base_url": base_url, "kernel": kernel, "patches": sorted(patches_with_hash, key=lambda p: p["name"])}
with open(args.filename, "w+") as f: with open(args.filename, "w+") as f:
json.dump(result, f, indent=2) json.dump(result, f, indent=2)