extract common code for patching kernel source fdorm openwrt

This commit is contained in:
Daniel Barlow 2023-03-18 19:17:58 +00:00
parent e40170f7d5
commit efd878dc5e
5 changed files with 55 additions and 60 deletions

View file

@ -40,13 +40,7 @@
module = {pkgs, config, ... }:
let
openwrt = pkgs.pkgsBuildBuild.fetchFromGitHub {
name = "openwrt-source";
repo = "openwrt";
owner = "openwrt";
rev = "a5265497a4f6da158e95d6a450cb2cb6dc085cab";
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
};
openwrt = pkgs.openwrt;
firmwareBlobs = pkgs.pkgsBuildBuild.fetchFromGitHub {
owner = "kvalo";
repo = "ath10k-firmware";
@ -96,9 +90,9 @@
};
rootDevice = "1f05";
dts = {
src = "${openwrt}/target/linux/ath79/dts/qca9531_glinet_gl-ar750.dts";
src = "${openwrt.src}/target/linux/ath79/dts/qca9531_glinet_gl-ar750.dts";
includes = [
"${openwrt}/target/linux/ath79/dts"
"${openwrt.src}/target/linux/ath79/dts"
];
};
@ -136,17 +130,7 @@
hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
};
extraPatchPhase = ''
cp -av ${openwrt}/target/linux/generic/files/* .
chmod -R u+w .
cp -av ${openwrt}/target/linux/ath79/files/* .
chmod -R u+w .
patches() {
for i in $* ; do patch --batch --forward -p1 < $i ;done
}
patches ${openwrt}/target/linux/generic/backport-5.15/*.patch
patches ${openwrt}/target/linux/generic/pending-5.15/*.patch
patches ${openwrt}/target/linux/generic/hack-5.15/*.patch
patches ${openwrt}/target/linux/ath79/patches-5.15/*.patch
${openwrt.applyPatches.ath79}
'';
config = {
MIPS_ELF_APPENDED_DTB = "y";

View file

@ -21,13 +21,7 @@
module = { pkgs, config, ...}:
let
inherit (pkgs.liminix.networking) interface;
openwrt = pkgs.fetchFromGitHub {
name = "openwrt-source";
repo = "openwrt";
owner = "openwrt";
rev = "a5265497a4f6da158e95d6a450cb2cb6dc085cab";
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
};
inherit (pkgs) openwrt;
mac80211 = pkgs.mac80211.override {
drivers = ["rt2800soc"];
klibBuild = config.outputs.kernel.modulesupport;
@ -55,9 +49,9 @@
rootDevice = "1f05";
dts = {
src = "${openwrt}/target/linux/ramips/dts/mt7620a_glinet_gl-mt300a.dts";
src = "${openwrt.src}/target/linux/ramips/dts/mt7620a_glinet_gl-mt300a.dts";
includes = [
"${openwrt}/target/linux/ramips/dts"
"${openwrt.src}/target/linux/ramips/dts"
];
};
networkInterfaces = rec {
@ -94,17 +88,7 @@
hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
};
extraPatchPhase = ''
cp -av ${openwrt}/target/linux/generic/files/* .
chmod -R u+w .
cp -av ${openwrt}/target/linux/ramips/files/* .
chmod -R u+w .
patches() {
for i in $* ; do patch --batch --forward -p1 < $i ;done
}
patches ${openwrt}/target/linux/generic/backport-5.15/*.patch
patches ${openwrt}/target/linux/generic/pending-5.15/*.patch
patches ${openwrt}/target/linux/generic/hack-5.15/*.patch
patches ${openwrt}/target/linux/ramips/patches-5.15/*.patch
${openwrt.applyPatches.ramips}
'';
config = {
MIPS_ELF_APPENDED_DTB = "y";

View file

@ -16,14 +16,8 @@
inherit (pkgs.liminix.networking) interface;
inherit (pkgs.liminix.services) oneshot;
inherit (pkgs.pseudofile) dir symlink;
inherit (pkgs) openwrt;
openwrt = pkgs.fetchFromGitHub {
name = "openwrt-source";
repo = "openwrt";
owner = "openwrt";
rev = "a5265497a4f6da158e95d6a450cb2cb6dc085cab";
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
};
mac80211 = pkgs.mac80211.override {
drivers = ["mt7603e"];
klibBuild = config.outputs.kernel.modulesupport;
@ -52,9 +46,9 @@
rootDevice = "1f05";
dts = {
src = "${openwrt}/target/linux/ramips/dts/mt7628an_glinet_gl-mt300n-v2.dts";
src = "${openwrt.src}/target/linux/ramips/dts/mt7628an_glinet_gl-mt300n-v2.dts";
includes = [
"${openwrt}/target/linux/ramips/dts"
"${openwrt.src}/target/linux/ramips/dts"
];
};
networkInterfaces = rec {
@ -109,17 +103,7 @@
hash = "sha256-yhO2cXIeIgUxkSZf/4aAsF11uxyh+UUZu6D1h92vCD8=";
};
extraPatchPhase = ''
cp -av ${openwrt}/target/linux/generic/files/* .
chmod -R u+w .
cp -av ${openwrt}/target/linux/ramips/files/* .
chmod -R u+w .
patches() {
for i in $* ; do patch --batch --forward -p1 < $i ;done
}
patches ${openwrt}/target/linux/generic/backport-5.15/*.patch
patches ${openwrt}/target/linux/generic/pending-5.15/*.patch
patches ${openwrt}/target/linux/generic/hack-5.15/*.patch
patches ${openwrt}/target/linux/ramips/patches-5.15/*.patch
${openwrt.applyPatches.ramips}
'';
config = {
MIPS_ELF_APPENDED_DTB = "y";

View file

@ -38,4 +38,6 @@
lzma = callPackage ./lzma {};
swconfig = callPackage ./swconfig {};
openwrt = callPackage ./openwrt {};
}

41
pkgs/openwrt/default.nix Normal file
View file

@ -0,0 +1,41 @@
{
fetchFromGitHub
, writeShellScript
}:
let
src = fetchFromGitHub {
name = "openwrt-source";
repo = "openwrt";
owner = "openwrt";
rev = "a5265497a4f6da158e95d6a450cb2cb6dc085cab";
hash = "sha256-YYi4gkpLjbOK7bM2MGQjAyEBuXJ9JNXoz/JEmYf8xE8=";
};
in {
inherit src;
applyPatches.ath79 = writeShellScript "apply-patches-ath79" ''
cp -av ${src}/target/linux/generic/files/* .
chmod -R u+w .
cp -av ${src}/target/linux/ath79/files/* .
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
patches ${src}/target/linux/generic/hack-5.15/*.patch
patches ${src}/target/linux/ath79/patches-5.15/*.patch
'';
applyPatches.ramips = writeShellScript "apply-patches-ramips" ''
cp -av ${src}/target/linux/generic/files/* .
chmod -R u+w .
cp -av ${src}/target/linux/ramips/files/* .
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
patches ${src}/target/linux/generic/hack-5.15/*.patch
patches ${src}/target/linux/ramips/patches-5.15/*.patch
'';
}