liminix

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

default.nix (2525B)


      1 {
      2   stdenv,
      3   git,
      4   python2,
      5   which,
      6   fetchgit,
      7   fetchFromGitHub,
      8   coccinelle,
      9 }:
     10 let
     11   donorTree = fetchFromGitHub {
     12     owner = "torvalds";
     13     repo = "linux";
     14     rev = "e2c1a934fd8e4288e7a32f4088ceaccf469eb74c"; # 5.15.94
     15     hash = "sha256-Jg3EgL86CseuzYMAlUG3CDWPCo8glMSIZs10l7EuhWI=";
     16   };
     17   backports = stdenv.mkDerivation {
     18     name = "linux-backports";
     19     version = "dfe0f60ca8a";
     20     nativeBuildInputs = [ python2 ];
     21 
     22     src = fetchgit {
     23       url = "https://git.kernel.org/pub/scm/linux/kernel/git/backports/backports.git";
     24       name = "backports";
     25       rev = "dfe0f60ca8a1065e63b4db703b3bd2708ee23a0e";
     26       hash = "sha256-V+unO0rCom+TZS7WuaXFrb3C1EBImmflCPuOoP+LvBY=";
     27     };
     28     buildPhase = ''
     29       patchShebangs .
     30     '';
     31     installPhase = ''
     32       mkdir -p $out
     33       cp -a . $out
     34       rm $out/patches/0073-netdevice-mtu-range.cocci
     35       # fq.patch is obsoleted by kernel commit 48a54f6bc45 and no longer
     36       # applies
     37       # rm $out/patches/0091-fq-no-siphash_key_t/fq.patch
     38       # don't know why this doesn't apply but it's only important for
     39       # compiling against linux < 4.1
     40       # rm $out/patches/0058-ptp_getsettime64/ptp_getsettime64.cocci
     41     '';
     42     patches = [
     43       # (fetchpatch {
     44       #   url = "https://github.com/telent/nixwrt/blob/28ff2559e811c740b0a2922f52291b335804857b/nixwrt/kernel/gentree-writable-outputs.patch";
     45       #   hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
     46       # })#
     47       ./gentree-writable-outputs.patch
     48       #      ./update-usb-sg-backport-patch.patch
     49       #      ./backport_kfree_sensitive.patch
     50     ];
     51   };
     52 in
     53 stdenv.mkDerivation rec {
     54   inherit donorTree;
     55   KERNEL_VERSION = builtins.substring 0 11 donorTree.rev;
     56   BACKPORTS_VERSION = backports.version;
     57   name = "backported-kernel-${KERNEL_VERSION}-${BACKPORTS_VERSION}";
     58 
     59   # gentree uses "which" at runtime to test for the presence of git,
     60   # and I don't have the patience to patch it out. There is no other
     61   # reason we need either of them as build inputs.
     62   depsBuildBuild = [ coccinelle ];
     63   nativeBuildInputs = [
     64     which
     65     git
     66     python2
     67   ];
     68 
     69   phases = [
     70     "backportFromFuture"
     71     "installPhase"
     72   ];
     73 
     74   backportFromFuture = ''
     75     echo $KERNEL_VERSION $BACKPORTS_VERSION
     76     WORK=`pwd`/build
     77     mkdir -p $WORK
     78     cat ${backports}/copy-list > copy-list
     79     echo 'include/linux/key.h' >> copy-list
     80     python  ${backports}/gentree.py --verbose --clean  --copy-list copy-list ${donorTree} $WORK
     81   '';
     82   installPhase = ''
     83     cp -a ./build/ $out
     84   '';
     85 }