liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

default.nix (2475B)


      1 { fetchFromGitHub, pkgsBuildBuild }:
      2 let
      3   src = fetchFromGitHub {
      4     name = "openwrt-source";
      5     repo = "openwrt";
      6     owner = "openwrt";
      7     rev = "refs/tags/v23.05.2";
      8     hash = "sha256-kP+cSOB6LiOMWs7g+ji7P7ehiDYDwRdmT4R5jSzw6K4=";
      9   };
     10   doPatch = family: ''
     11     cp -av ${src}/target/linux/generic/files/* .
     12     chmod -R u+w .
     13     cp -av ${src}/target/linux/${family}/files/* .
     14     chmod -R u+w .
     15     test -d ${src}/target/linux/${family}/files-5.15/ && cp -av ${src}/target/linux/${family}/files-5.15/* .
     16     chmod -R u+w .
     17     patches() {
     18       for i in $* ; do patch --batch --forward -p1 < $i ;done
     19     }
     20     patches ${src}/target/linux/generic/backport-5.15/*.patch
     21     patches ${src}/target/linux/generic/pending-5.15/*.patch
     22     # This patch breaks passing the DTB to kexeced kernel, so let's
     23     # get rid of it. It's not needed anyway as we pass the cmdline
     24     # in the dtb
     25     patch --batch -p1 --reverse <  ${src}/target/linux/generic/pending-5.15/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch
     26     patches ${src}/target/linux/generic/hack-5.15/*.patch
     27     patches ${src}/target/linux/${family}/patches-5.15/*.patch
     28     patches ${./make-mtdsplit-jffs2-endian-agnostic.patch}
     29   '';
     30 in
     31 {
     32   inherit src;
     33 
     34   # The kernel sources typically used with this version of openwrt
     35   # You can find this in `include/kernel-5.15` or similar in the
     36   # openwrt sources
     37   kernelSrc = pkgsBuildBuild.fetchurl {
     38     name = "linux.tar.gz";
     39     url = "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.gz";
     40     hash = "sha256-PkdzUKZ0IpBiWe/RS70J76JKnBFzRblWcKlaIFNxnHQ=";
     41   };
     42   kernelVersion = "5.15.137";
     43 
     44   applyPatches.ath79 = doPatch "ath79";
     45   applyPatches.ramips = doPatch "ramips";
     46   applyPatches.mediatek = doPatch "mediatek"; # aarch64
     47   applyPatches.mvebu = doPatch "mvebu"; # arm
     48 
     49   applyPatches.rt2x00 = ''
     50     PATH=${pkgsBuildBuild.patchutils}/bin:$PATH
     51     for i in ${src}/package/kernel/mac80211/patches/rt2x00/6*.patch ; do
     52       fixed=$(basename $i).fixed
     53       sed '/depends on m/d'  < $i | sed 's/CPTCFG_/CONFIG_/g' | recountdiff | filterdiff -x '*/local-symbols' > $fixed
     54       case $fixed in
     55         606-*)
     56           ;;
     57         611-*)
     58           filterdiff -x '*/rt2x00.h' < $fixed | patch --forward -p1
     59           ;;
     60         601-*|607-*)
     61           filterdiff -x '*/rt2x00_platform.h' < $fixed | patch --forward -p1
     62           ;;
     63         *)
     64           cat $fixed | patch --forward -p1
     65           ;;
     66       esac
     67     done
     68   '';
     69 }