commit 5af28615f1fd4639423e48dd39c7c7efe4c36a90
parent e8a60d286006abb8a4d559e13df5e8659ffefab3
Author: Daniel Barlow <dan@telent.net>
Date: Sat, 28 Mar 2026 21:15:51 +0000
gl-ar750: update to newer kernel + openwrt
this device is not (yet?) in mainline, but openwrt 25.12 has
the right patches to make it work with linux 6.12
Diffstat:
3 files changed, 110 insertions(+), 3 deletions(-)
diff --git a/devices/gl-ar750/default.nix b/devices/gl-ar750/default.nix
@@ -60,7 +60,7 @@
}:
let
inherit (lib) mkIf;
- openwrt = pkgs.openwrt;
+ openwrt = pkgs.openwrt_25_12;
firmwareBlobs = pkgs.pkgsBuildBuild.fetchgit {
url = "https://git.codelinaro.org/clo/ath-firmware/ath10k-firmware";
rev = "5d63529ffc6e24974bc7c45b28fd1c34573126eb";
@@ -175,13 +175,14 @@
appendDTB = true;
};
kernel = {
- # Mainline linux 5.19 doesn't have device-tree support for
+ # Mainline linux 6.12 doesn't have device-tree support for
# this device or even for the SoC, so we use the extensive
# OpenWrt kernel patches
+ src = openwrt.kernelSrc;
+ version = openwrt.kernelVersion;
extraPatchPhase = ''
${openwrt.applyPatches.ath79}
sed -i.bak -e '\,include <linux/hw_random.h>,a #include <linux/gpio/driver.h>' drivers/net/wireless/ath/ath9k/ath9k.h # context reqd for next patch
- patch -p1 < ${openwrt.src}/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch
'';
config = {
diff --git a/pkgs/default.nix b/pkgs/default.nix
@@ -135,6 +135,7 @@ in
odhcp6c = callPackage ./odhcp6c { };
openwrt = callPackage ./openwrt { };
openwrt_24_10 = callPackage ./openwrt/2410.nix { };
+ openwrt_25_12 = callPackage ./openwrt/2512.nix { };
output-template = callPackage ./output-template { };
ppp = callPackage ./ppp { };
pppoe = callPackage ./pppoe { };
diff --git a/pkgs/openwrt/2512.nix b/pkgs/openwrt/2512.nix
@@ -0,0 +1,105 @@
+{
+ fetchFromGitHub,
+ pkgsBuildBuild,
+ lib,
+ cpio
+}:
+let
+ src = fetchFromGitHub {
+ name = "openwrt-source";
+ repo = "openwrt";
+ owner = "openwrt";
+ rev = "v25.12.1";
+ hash = "sha256-RshgHcH5d1pmS00XPj1DAmfApT4xXrC+QI4Vg2rd/dE=";
+ };
+ # we don't use different kernel versions for monolith and mac80211 as
+ # openwrt does, so we also need an older openwrt version with
+ # the wireless patches that correspond to 6.12.x
+ oldSrc = fetchFromGitHub {
+ name = "openwrt-source";
+ repo = "openwrt";
+ owner = "openwrt";
+ rev = "c8eacec725dce34c7b621f00c9bce814fe413759";
+ hash = "sha256-YTfAWmFPXPXFQ56QGRLgCc/QY+RndOdVdcgtBaZsh1E=";
+ };
+ kernelVersion = "6.12.77";
+ kernelSeries = lib.versions.majorMinor kernelVersion;
+ doPatch = family: ''
+ tar -C ${src}/target/linux/generic/files -cf - . | tar xpf -
+ chmod -R u+w .
+ tar -C ${src}/target/linux/${family}/files -cf - . | tar xpf -
+ chmod -R u+w .
+ test -d ${src}/target/linux/${family}/files-${kernelSeries}/ && ( tar -C ${src}/target/linux/${family}/files-${kernelSeries} -cf - . | tar xpf -)
+ chmod -R u+w .
+
+ ensure_patch() {
+ echo Applying $1
+ # skip patches which are already applied by testing if they
+ # can be dry-run in reverse
+ patch --batch --forward -p1 < $1 ||
+ patch --batch --reverse --dry-run -p1 < $1
+
+ }
+ patches() {
+ for i in $* ; do
+ ensure_patch $i
+ done
+ }
+
+ patches ${src}/target/linux/generic/backport-${kernelSeries}/*.patch
+ patches ${src}/target/linux/generic/pending-${kernelSeries}/*.patch
+ patches ${src}/target/linux/generic/hack-${kernelSeries}/*.patch
+ patches ${src}/target/linux/${family}/patches-${kernelSeries}/*.patch
+
+ for kconfig in $(find drivers/net/wireless/ -name Kconfig); do
+ sed -i.bak -E -e '/^((\s+))tristate/a\
+\tdepends on m' $kconfig
+ done
+
+ mkdir backport_patches
+ for f in ${oldSrc}/package/kernel/mac80211/patches/*.*; do
+ out=backport_patches/`basename $f`
+ sed < $f 's/CPTCFG_/CONFIG_/g' > $out
+ ensure_patch $out
+ done
+ '';
+in
+{
+ inherit src;
+
+ # The kernel sources typically used with this version of openwrt
+ # You can find this in `include/kernel-5.15` or similar in the
+ # openwrt sources
+ kernelSrc = pkgsBuildBuild.fetchurl {
+ name = "linux.tar.gz";
+ url = "https://cdn.kernel.org/pub/linux/kernel/v${lib.versions.major kernelVersion}.x/linux-${kernelVersion}.tar.gz";
+ hash = "sha256-kPvUXXvWWmZ+B3ONP7iC2zlwaBom/RCNw6oxXeb47zU=";
+ };
+ inherit kernelVersion;
+
+ applyPatches.ath79 = doPatch "ath79";
+ applyPatches.ramips = doPatch "ramips";
+ applyPatches.mediatek = doPatch "mediatek"; # aarch64
+ applyPatches.mvebu = doPatch "mvebu"; # arm
+
+ applyPatches.rt2x00 = ''
+ PATH=${pkgsBuildBuild.patchutils}/bin:$PATH
+ for i in ${src}/package/kernel/mac80211/patches/rt2x00/6*.patch ; do
+ fixed=$(basename $i).fixed
+ sed '/depends on m/d' < $i | sed 's/CPTCFG_/CONFIG_/g' | recountdiff | filterdiff -x '*/local-symbols' > $fixed
+ case $fixed in
+ 606-*)
+ ;;
+ 611-*)
+ filterdiff -x '*/rt2x00.h' < $fixed | patch --forward -p1
+ ;;
+ 601-*|607-*)
+ filterdiff -x '*/rt2x00_platform.h' < $fixed | patch --forward -p1
+ ;;
+ *)
+ cat $fixed | patch --forward -p1
+ ;;
+ esac
+ done
+ '';
+}