1{ stdenv, lib, buildPackages, fetchFromGitHub, perl, buildLinux, ... } @ args:
2
3let
4 modDirVersion = "4.14.70";
5 tag = "1.20180919";
6in
7lib.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 = "1zjvzk6rhrn3ngc012gjq3v7lxn8hy89ljb7fqwld5g7py9lkf0b";
16 };
17
18 defconfig = {
19 "armv6l-linux" = "bcmrpi_defconfig";
20 "armv7l-linux" = "bcm2709_defconfig";
21 "aarch64-linux" = "bcmrpi3_defconfig";
22 }.${stdenv.hostPlatform.system} or (throw "linux_rpi not supported on '${stdenv.hostPlatform.system}'");
23
24 features = {
25 efiBootStub = false;
26 } // (args.features or {});
27
28 extraMeta.hydraPlatforms = [ "aarch64-linux" ];
29})) (oldAttrs: {
30 postConfigure = ''
31 # The v7 defconfig has this set to '-v7' which screws up our modDirVersion.
32 sed -i $buildRoot/.config -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/'
33 '';
34
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 postFixup = ''
38 dtbDir=${if stdenv.isAarch64 then "$out/dtbs/broadcom" else "$out/dtbs"}
39 rm $dtbDir/bcm283*.dtb
40 copyDTB() {
41 cp -v "$dtbDir/$1" "$dtbDir/$2"
42 }
43 '' + lib.optionalString (lib.elem stdenv.hostPlatform.system ["armv6l-linux"]) ''
44 copyDTB bcm2708-rpi-0-w.dtb bcm2835-rpi-zero.dtb
45 copyDTB bcm2708-rpi-0-w.dtb bcm2835-rpi-zero-w.dtb
46 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-a.dtb
47 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b.dtb
48 copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b-rev2.dtb
49 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-a-plus.dtb
50 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-b-plus.dtb
51 copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-zero.dtb
52 copyDTB bcm2708-rpi-cm.dtb bcm2835-rpi-cm.dtb
53 '' + lib.optionalString (lib.elem stdenv.hostPlatform.system ["armv7l-linux"]) ''
54 copyDTB bcm2709-rpi-2-b.dtb bcm2836-rpi-2-b.dtb
55 '' + lib.optionalString (lib.elem stdenv.hostPlatform.system ["armv7l-linux" "aarch64-linux"]) ''
56 copyDTB bcm2710-rpi-3-b.dtb bcm2837-rpi-3-b.dtb
57 copyDTB bcm2710-rpi-3-b-plus.dtb bcm2837-rpi-3-b-plus.dtb
58 copyDTB bcm2710-rpi-cm3.dtb bcm2837-rpi-cm3.dtb
59 '';
60})