{ fetchFromGitHub, pkgsBuildBuild }: let src = fetchFromGitHub { name = "openwrt-source"; repo = "openwrt"; owner = "openwrt"; # snapshot my OpenWRT One came with rev = "3098b4bf0725509aee13fe1560ce5a9188ea2fc7"; hash = "sha256-we61HQ+XppOOw1AhQjNZtmN4IJDsV+dmKT/d9341jJs="; }; doPatch = family: '' cp -av ${src}/target/linux/generic/files/* . chmod -R u+w . cp -av ${src}/target/linux/${family}/files/* . chmod -R u+w . test -d ${src}/target/linux/${family}/files-6.6/ && cp -av ${src}/target/linux/${family}/files-6.6/* . chmod -R u+w . patches() { for i in $* ; do patch --batch --forward -p1 < $i || exit 1;done } patches ${src}/target/linux/generic/backport-6.6/*.patch # missing from backport-6.6/752-*? patch -p0 < ${./mtk_rename.patch} patches ${src}/target/linux/generic/pending-6.6/*.patch # This patch breaks passing the DTB to kexeced kernel, so let's # get rid of it. It's not needed anyway as we pass the cmdline # in the dtb patch --batch -p1 --reverse < ${src}/target/linux/generic/pending-6.6/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch patches ${src}/target/linux/generic/hack-6.6/*.patch patches ${src}/target/linux/${family}/patches-6.6/*.patch patches ${./make-mtdsplit-jffs2-endian-agnostic.patch} ''; in { inherit src; # The kernel sources typically used with this version of openwrt # You can find this in `include/kernel-6.6` or similar in the # openwrt sources kernelSrc = pkgsBuildBuild.fetchurl { name = "linux.tar.gz"; url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.57.tar.gz"; hash = "sha256-LP9tktb/HX5LPZt6m7FO9k38g31tyl714kqV0j4NTmc="; }; kernelVersion = "6.6.57"; 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 ''; }