2019-06-10 02:32:37 +03:00
|
|
|
{
|
|
|
|
mobile-nixos
|
2019-06-10 04:26:32 +03:00
|
|
|
, stdenv
|
|
|
|
, hostPlatform
|
2018-11-18 02:24:55 +03:00
|
|
|
, fetchFromGitHub
|
2019-06-10 02:32:37 +03:00
|
|
|
, kernelPatches ? [] # FIXME
|
2018-11-18 02:24:55 +03:00
|
|
|
, dtbTool
|
|
|
|
}:
|
|
|
|
|
2019-06-10 04:26:32 +03:00
|
|
|
#
|
|
|
|
# Note:
|
|
|
|
# This kernel build is special, it supports both armv7l and aarch64.
|
|
|
|
# This is because motorola ships an armv7l userspace from stock ROM.
|
|
|
|
#
|
|
|
|
# in local.nix:
|
2019-09-18 23:55:15 +03:00
|
|
|
# mobile.system.system = lib.mkForce "armv7l-linux";
|
2019-06-10 04:26:32 +03:00
|
|
|
#
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (stdenv.lib) optionalString;
|
|
|
|
cpuName = hostPlatform.parsed.cpu.name;
|
|
|
|
in
|
2019-06-10 02:32:37 +03:00
|
|
|
(mobile-nixos.kernel-builder-gcc6 {
|
|
|
|
version = "3.18.71";
|
2019-06-10 04:26:32 +03:00
|
|
|
configfile = ./. + "/config.${cpuName}";
|
2018-11-18 02:24:55 +03:00
|
|
|
|
2019-06-10 04:26:32 +03:00
|
|
|
file = if (cpuName == "aarch64") then "Image.gz" else "zImage";
|
|
|
|
hasDTB = (cpuName == "aarch64");
|
2018-11-18 02:24:55 +03:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2018-11-19 05:34:00 +03:00
|
|
|
owner = "LineageOS";
|
|
|
|
repo = "android_kernel_motorola_msm8953";
|
|
|
|
rev = "80530de6e297dd0f0ba479c0dcc4ddb7c9e90e24"; # lineage-15.1
|
|
|
|
sha256 = "0qw8x61ycpkk5pqvs9k2abr5lq56ga5dml6vkygvmi8psm2g6kg1";
|
2018-11-18 02:24:55 +03:00
|
|
|
};
|
2019-06-10 02:32:37 +03:00
|
|
|
|
2018-11-18 02:24:55 +03:00
|
|
|
patches = [
|
|
|
|
./04_fix_camera_msm_isp.patch
|
|
|
|
./05_misc_msm_fixes.patch
|
2018-11-19 05:34:00 +03:00
|
|
|
./06_prima_gcc6.patch
|
2018-11-18 02:24:55 +03:00
|
|
|
./99_framebuffer.patch
|
2019-12-04 08:18:00 +03:00
|
|
|
./0001-Allow-building-WCD9335_CODEC-without-REGMAP_ALLOW_WR.patch
|
|
|
|
./0005-Allow-building-with-sound-disabled.patch
|
2018-11-18 02:24:55 +03:00
|
|
|
];
|
|
|
|
|
2019-06-10 02:32:37 +03:00
|
|
|
isModular = false;
|
|
|
|
|
|
|
|
}).overrideAttrs({ postInstall ? "", postPatch ? "", ... }: {
|
2019-06-10 04:26:32 +03:00
|
|
|
installTargets = [ "zinstall" "dtbs" ];
|
2019-06-10 02:32:37 +03:00
|
|
|
postPatch = postPatch + ''
|
2018-11-18 02:24:55 +03:00
|
|
|
cp -v "${./compiler-gcc6.h}" "./include/linux/compiler-gcc6.h"
|
|
|
|
|
2019-06-10 02:32:37 +03:00
|
|
|
# FIXME : factor out
|
|
|
|
(
|
2018-11-18 02:24:55 +03:00
|
|
|
# Remove -Werror from all makefiles
|
|
|
|
local i
|
|
|
|
local makefiles="$(find . -type f -name Makefile)
|
|
|
|
$(find . -type f -name Kbuild)"
|
|
|
|
for i in $makefiles; do
|
|
|
|
sed -i 's/-Werror-/-W/g' "$i"
|
2019-06-10 02:32:37 +03:00
|
|
|
sed -i 's/-Werror=/-W/g' "$i"
|
2018-11-18 02:24:55 +03:00
|
|
|
sed -i 's/-Werror//g' "$i"
|
|
|
|
done
|
|
|
|
)
|
|
|
|
'';
|
2019-06-10 02:32:37 +03:00
|
|
|
postInstall = postInstall + ''
|
2019-06-10 04:26:32 +03:00
|
|
|
mkdir -p "$out/dtbs/"
|
|
|
|
''
|
|
|
|
+ optionalString (cpuName == "aarch64") ''
|
2019-06-10 02:32:37 +03:00
|
|
|
${dtbTool}/bin/dtbTool -s 2048 -p "scripts/dtc/" -o "$out/dtbs/motorola-addison.img" "$out/dtbs/qcom/"
|
2019-06-10 04:26:32 +03:00
|
|
|
''
|
|
|
|
+ optionalString (cpuName == "armv7l") ''
|
|
|
|
${dtbTool}/bin/dtbTool -s 2048 -p "scripts/dtc/" -o "$out/dtbs/motorola-addison.img" "arch/arm/boot"
|
|
|
|
''
|
|
|
|
;
|
2019-06-10 02:32:37 +03:00
|
|
|
})
|