Created
November 16, 2021 01:32
-
-
Save danielfullmer/3d33d240208dcfdc9287072d06823ede to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, pkgs, lib, ... }: | |
let | |
inherit (lib) types mkIf mkOption optionalString; | |
selfExtractorDir = | |
if config.deviceFamily == "raviole" | |
then "${config.source.dirs."device/google/${config.deviceFamily}".src}/self-extractors_${config.device}" | |
else "${config.source.dirs."device/google/${config.deviceFamily}".src}/self-extractors"; | |
# TODO: rename config.build.apv.unpackedImg to something else, since it's no longer apv-specific | |
vendorDir = pkgs.runCommand "${config.device}-vendor" {} ('' | |
mkdir -p $out | |
cp --no-preserve=mode -r ${selfExtractorDir}/root/. $out | |
cp --no-preserve=mode ${selfExtractorDir}/google_devices/{COPYRIGHT,LICENSE} $out | |
cp --no-preserve=mode ${selfExtractorDir}/google_devices/staging/*.{mk,txt} $out | |
mv $out/Android.bp.txt $out/proprietary/Android.bp | |
mv $out/Android.mk $out/proprietary/Android.mk | |
# See also device/common/generate-package.sh | |
EXTRACT_LIST_FILENAME=${selfExtractorDir}/extract-lists.txt | |
# TODO: COMPANY | |
TO_EXTRACT=`sed -n -e '/'" $COMPANY"'/,/;;/ p' $EXTRACT_LIST_FILENAME | tail -n+3 | head -n-2 | sed -e 's/\\\//g'` | |
mkdir -p $out/proprietary/lib64 | |
for ONE_FILE in $TO_EXTRACT; do | |
# Remove IMAGES prefix | |
ONE_FILE=''${ONE_FILE#IMAGES/} | |
if [[ $ONE_FILE == RADIO/* ]]; then | |
continue | |
fi | |
if [[ $ONE_FILE == */lib64/* ]]; then | |
OUTDIR=$out/proprietary/lib64 | |
else | |
OUTDIR=$out/proprietary | |
fi | |
cp --no-preserve=mode ${config.build.apv.unpackedImg}/$ONE_FILE $OUTDIR | |
done | |
cp --no-preserve=mode ${config.build.apv.unpackedImg}/bootloader-*.img $out/proprietary/bootloader.img | |
cp --no-preserve=mode ${config.build.apv.unpackedImg}/radio-*.img $out/proprietary/radio.img | |
'' + optionalString (config.deviceFamily == "raviole") '' | |
# Needed for raviole apks to get the right selinux domain | |
substituteInPlace $out/proprietary/Android.mk \ | |
--replace "LOCAL_CERTIFICATE := platform" "LOCAL_CERTIFICATE := PRESIGNED" | |
''); | |
in | |
{ | |
options = { | |
pixel.useFactoryVendorImage = mkOption { | |
default = false; | |
type = types.bool; | |
description = "Use device vendor binaries from factory image"; | |
}; | |
}; | |
config = mkIf (config.pixel.useFactoryVendorImage && !config.apv.enable && !config.pixel.useUpstreamDriverBinaries) { | |
assertions = [ | |
{ assertion = !config.apv.enable && !config.pixel.useUpstreamDriverBinaries; | |
message = "Only one of pixel.useFactoryVendor, pixel.useUpstreamDriverBinaries, and apv.enable can be true"; | |
} | |
]; | |
source.dirs."device/google/raviole".patches = mkIf (config.deviceFamily == "raviole") [ ./0001-raven-add-files-missing-from-self-extract-directory.patch ]; | |
source.dirs."vendor/google_devices/${config.device}".src = vendorDir; | |
# TODO: Unify with that in modules/pixel/driver-binaries.nix | |
signing.prebuiltImages = let | |
prebuilt = partition: "${config.source.dirs."vendor/google_devices/${config.device}".src}/proprietary/${partition}.img"; | |
in [ | |
(prebuilt "vendor") | |
(prebuilt "vendor_dlkm") # TODO: Only for raviole | |
]; | |
# Override/unset some properties in factory vendor.img | |
# Product partition has precendence over vendor partition. | |
# See build/make/Changes.md | |
product.extraConfig = mkIf (config.deviceFamily == "raviole") '' | |
PRODUCT_PRODUCT_PROPERTIES += \ | |
ro.atrace.core.services= \ | |
ro.com.google.clientidbase= \ | |
ro.error.receiver.system.apps= \ | |
ro.vendor.camera.extensions.package= \ | |
ro.vendor.camera.extensions.service= \ | |
''; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment