liminix

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

default.nix (2511B)


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