anchor.diff:      make modules_install $makeFlags "''${makeFlagsArray[@]}" \
         $installFlags "''${installFlagsArray[@]}"
       rm -f $out/lib/modules/${modDirVersion}/build
  -    cd $buildRoot/..
       mv $buildRoot $out/lib/modules/${modDirVersion}/build
     '' else optionalString installsFirmware ''
       make firmware_install $makeFlags "''${makeFlagsArray[@]}" \
  
positive.code:     ];
      platforms = lib.platforms.linux;
    };
  }; in self
  
negative.code:   ++ optional installsFirmware "INSTALL_FW_PATH=$(out)/lib/firmware";
  in
  
  stdenv.mkDerivation {
    name = "linux-${version}";
  
    enableParallelBuilding = true;
  
    passthru = {
      inherit version modDirVersion config kernelPatches src;
    };
  
    sourceRoot = stdenv.mkDerivation {
      name = "linux-${version}-source";
  
      inherit src;
  
      patches = map (p: p.patch) kernelPatches;
  
      phases = [ "unpackPhase" "patchPhase" "installPhase" ]; 
  
      prePatch = ''
        for mf in $(find -name Makefile -o -name Makefile.include -o -name install.sh); do
            echo "stripping FHS paths in \`$mf'..."
            sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g'
        done
        sed -i Makefile -e 's|= depmod|= ${kmod}/sbin/depmod|'
      '';
  
      installPhase = ''
        cd ..
        mv $sourceRoot $out
      '';
    };
  
    unpackPhase = ''
      mkdir build
      export buildRoot="$(pwd)/build"
      ln -sv ${configfile} $buildRoot/.config
      cd $sourceRoot
    '';
  
    configurePhase = ''
      runHook preConfigure
      make $makeFlags "''${makeFlagsArray[@]}" oldconfig
      runHook postConfigure
    '';
  
  