liminix/pkgs/openwrt/default.nix

62 lines
2 KiB
Nix
Raw Normal View History

{
fetchFromGitHub
, writeShellScript
2024-03-25 00:21:52 +01:00
, pkgsBuildBuild
}:
let
src = fetchFromGitHub {
name = "openwrt-source";
repo = "openwrt";
owner = "openwrt";
2024-01-25 12:29:03 +01:00
rev = "refs/tags/v23.05.2";
hash = "sha256-kP+cSOB6LiOMWs7g+ji7P7ehiDYDwRdmT4R5jSzw6K4=";
};
2023-03-19 10:55:39 +01:00
doPatch = family : ''
cp -av ${src}/target/linux/generic/files/* .
chmod -R u+w .
2023-03-19 10:55:39 +01:00
cp -av ${src}/target/linux/${family}/files/* .
2024-02-20 23:23:04 +01:00
chmod -R u+w .
2023-10-01 23:12:13 +02:00
test -d ${src}/target/linux/${family}/files-5.15/ && cp -av ${src}/target/linux/${family}/files-5.15/* .
chmod -R u+w .
patches() {
for i in $* ; do patch --batch --forward -p1 < $i ;done
}
patches ${src}/target/linux/generic/backport-5.15/*.patch
patches ${src}/target/linux/generic/pending-5.15/*.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-5.15/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch
patches ${src}/target/linux/generic/hack-5.15/*.patch
2023-03-19 10:55:39 +01:00
patches ${src}/target/linux/${family}/patches-5.15/*.patch
patches ${./make-mtdsplit-jffs2-endian-agnostic.patch}
'';
2023-03-19 10:55:39 +01:00
in {
inherit src;
applyPatches.ath79 = doPatch "ath79";
applyPatches.ramips = doPatch "ramips";
2023-10-01 23:12:13 +02:00
applyPatches.mediatek = doPatch "mediatek"; # aarch64
2023-11-24 23:43:58 +01:00
applyPatches.mvebu = doPatch "mvebu"; # arm
2024-03-25 00:21:52 +01:00
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
'';
}