1{ stdenv, buildPackages, fetchFromGitHub, perl, buildLinux, ... } @ args:
2
3let
4 modDirVersion = "4.14.50";
5 tag = "1.20180619";
6in
7stdenv.lib.overrideDerivation (buildLinux (args // rec {
8 version = "${modDirVersion}-${tag}";
9 inherit modDirVersion;
10
11 src = fetchFromGitHub {
12 owner = "raspberrypi";
13 repo = "linux";
14 rev = "raspberrypi-kernel_${tag}-1";
15 sha256 = "0yccz8j3vrzv6h23b7yn7dx84kkzq3dmicm3shhz18nkpyyq71ch";
16 };
17
18 defconfig = {
19 "armv6l-linux" = "bcmrpi_defconfig";
20 "armv7l-linux" = "bcm2709_defconfig";
21 }.${stdenv.hostPlatform.system} or (throw "linux_rpi not supported on '${stdenv.hostPlatform.system}'");
22
23 features = {
24 efiBootStub = false;
25 } // (args.features or {});
26
27 extraMeta.hydraPlatforms = [];
28})) (oldAttrs: {
29 postConfigure = ''
30 # The v7 defconfig has this set to '-v7' which screws up our modDirVersion.
31 sed -i $buildRoot/.config -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/'
32 '';
33
34 postFixup = ''
35 # Make copies of the DTBs named after the upstream names so that U-Boot finds them.
36 # This is ugly as heck, but I don't know a better solution so far.
37 rm $out/dtbs/bcm283*.dtb
38 copyDTB() {
39 cp -v "$out/dtbs/$1" "$out/dtbs/$2"
40 }
41
42 copyDTB bcm2708-rpi-0-w.dtb bcm2835-rpi-zero.dtb
43 copyDTB bcm2708-rpi-0-w.dtb bcm2835-rpi-zero-w.dtb
44 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-a.dtb
45 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b.dtb
46 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b-rev2.dtb
47 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-a-plus.dtb
48 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-b-plus.dtb
49 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-zero.dtb
50 copyDTB bcm2708-rpi-cm.dtb bcm2835-rpi-cm.dtb
51 copyDTB bcm2709-rpi-2-b.dtb bcm2836-rpi-2-b.dtb
52 copyDTB bcm2710-rpi-3-b.dtb bcm2837-rpi-3-b.dtb
53 copyDTB bcm2710-rpi-3-b-plus.dtb bcm2837-rpi-3-b-plus.dtb
54 copyDTB bcm2710-rpi-cm3.dtb bcm2837-rpi-cm3.dtb
55 '';
56})