1
0
forked from dan/liminix
liminix/pkgs/openwrt/default.nix

80 lines
2.9 KiB
Nix
Raw Normal View History

2024-12-30 17:10:16 +00:00
{ fetchFromGitHub, pkgsBuildBuild, linux-firmware, fetchzip }:
let
src = fetchFromGitHub {
name = "openwrt-source";
repo = "openwrt";
owner = "openwrt";
2024-12-18 13:17:46 +00:00
# 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 .
2023-03-19 09:55:39 +00:00
cp -av ${src}/target/linux/${family}/files/* .
2024-02-20 22:23:04 +00:00
chmod -R u+w .
2024-12-18 13:17:46 +00:00
test -d ${src}/target/linux/${family}/files-6.6/ && cp -av ${src}/target/linux/${family}/files-6.6/* .
chmod -R u+w .
patches() {
2024-12-18 13:17:46 +00:00
for i in $* ; do patch --batch --forward -p1 < $i || exit 1;done
}
2024-12-18 13:17:46 +00:00
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
2024-12-18 13:17:46 +00:00
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}
'';
2023-03-19 09:55:39 +00:00
in {
inherit src;
# The kernel sources typically used with this version of openwrt
2024-12-18 13:17:46 +00:00
# You can find this in `include/kernel-6.6` or similar in the
# openwrt sources
kernelSrc = pkgsBuildBuild.fetchurl {
name = "linux.tar.gz";
2024-12-18 13:17:46 +00:00
url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.57.tar.gz";
hash = "sha256-LP9tktb/HX5LPZt6m7FO9k38g31tyl714kqV0j4NTmc=";
};
2024-12-18 13:17:46 +00:00
kernelVersion = "6.6.57";
2024-12-30 17:10:16 +00:00
# From package/firmware/linux-firmware/Makefile
linux-firmware = linux-firmware.overrideAttrs(a: {
src = fetchzip {
url = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/linux-firmware-20241017.tar.gz";
hash = "sha256-q4StJdoLCHQThFTzhxETDYlQP/ywmb3vwCr13xtrQzc=";
};
});
2023-03-19 09:55:39 +00:00
applyPatches.ath79 = doPatch "ath79";
applyPatches.ramips = doPatch "ramips";
2023-10-01 21:12:13 +00:00
applyPatches.mediatek = doPatch "mediatek"; # aarch64
2023-11-24 22:43:58 +00:00
applyPatches.mvebu = doPatch "mvebu"; # arm
2024-03-24 23:21:52 +00: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
'';
}