diff --git a/devices/asus-z00t/default.nix b/devices/asus-z00t/default.nix index fed990e1..ac915f52 100644 --- a/devices/asus-z00t/default.nix +++ b/devices/asus-z00t/default.nix @@ -2,9 +2,10 @@ { mobile.device.name = "asus-z00t"; - mobile.device.info = (lib.importJSON ../postmarketOS-devices.json).asus-z00t // { + mobile.device.info = (lib.importJSON ../postmarketOS-devices.json).asus-z00t // rec { # TODO : make kernel part of options. kernel = pkgs.callPackage ./kernel { kernelPatches = pkgs.defaultKernelPatches; }; + dtb = "${kernel}/dtbs/asus-z00t.img"; }; mobile.hardware = { # This could also be pre-built option types? diff --git a/devices/asus-z00t/kernel/config-asus-z00t.aarch64 b/devices/asus-z00t/kernel/config.aarch64 similarity index 100% rename from devices/asus-z00t/kernel/config-asus-z00t.aarch64 rename to devices/asus-z00t/kernel/config.aarch64 diff --git a/devices/asus-z00t/kernel/default.nix b/devices/asus-z00t/kernel/default.nix index f5469e84..a3931a08 100644 --- a/devices/asus-z00t/kernel/default.nix +++ b/devices/asus-z00t/kernel/default.nix @@ -1,30 +1,23 @@ -{ stdenv -, overrideCC -, gcc6 -, fetchurl +{ + mobile-nixos , fetchFromGitHub -, linuxManualConfig -, firmwareLinuxNonfree -, bison, flex -, binutils-unwrapped +, kernelPatches ? [] # FIXME , dtbTool -, kernelPatches ? [] -, buildPackages }: -# Inspired by https://github.com/thefloweringash/rock64-nix/blob/master/packages/linux_ayufan_4_4.nix -# Then in turn inspired by the postmarketos APKBUILDs. - -let - modDirVersion = "3.10.108"; - - version = "${modDirVersion}"; +(mobile-nixos.kernel-builder-gcc6 { + version = "3.10.108"; + configfile = ./config.aarch64; + dtb = "unknown"; + #file = "vmlinuz-dtb"; + file = "Image.gz"; src = fetchFromGitHub { owner = "LineageOS"; repo = "android_kernel_asus_msm8916"; rev = "d56000991e7d90e3a75afd86fb2f3c779232ff29"; # lineage-15.1 sha256 = "079sm5z0ml0ijm866ga5mzwnix4wzvida0469vymbrh8mhz47p4r"; }; + patches = [ ./0001-Porting-changes-found-in-LineageOS-android_kernel_cy.patch ./01_fix_gcc6_errors.patch @@ -33,97 +26,27 @@ let ./90_dtbs-install.patch ./99_framebuffer.patch ]; - postPatch = '' - patchShebangs . + isModular = false; + +}).overrideAttrs({ postInstall ? "", postPatch ? "", ... }: { + installTargets = [ "zinstall" ]; + postPatch = postPatch + '' cp -v "${./compiler-gcc6.h}" "./include/linux/compiler-gcc6.h" - - # 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" - sed -i 's/-Werror//g' "$i" - done - echo "Patched out -Werror" ''; + postInstall = postInstall + '' + ${dtbTool}/bin/dtbTool -s 2048 -p "scripts/dtc/" -o "arch/arm64/boot/asus-z00t.img" "arch/arm/boot/" + cp "arch/arm64/boot/asus-z00t.img" "$out/dtbs/asus-z00t.img" - additionalInstall = '' - # Generate master DTB (deviceinfo_bootimg_qcdt) - ${dtbTool}/bin/dtbTool -s 2048 -p "scripts/dtc/" -o "arch/arm64/boot/dt.img" "arch/arm/boot/" - - mkdir -p "$out/boot" - cp "arch/arm64/boot/dt.img" \ - "$out/boot/dt.img" - - # Copies the dtb, could always be useful. mkdir -p $out/dtb for f in arch/*/boot/dts/*.dtb; do cp -v "$f" $out/dtb/ done - # Copies the .config file to output. - # Helps ensuring sanity. - cp -v .config $out/src.config - - # Finally, makes Image.gz-dtb image ourselves. - # Somehow the build system has issues. - ( - cd $out - cat Image.gz dtb/*.dtb > vmlinuz-dtb - ) +# # FIXME: understand the specifics of why this needs to be catted together. +# ( +# cd $out +# cat Image.gz dtb/*.dtb > vmlinuz-dtb +# ) ''; -in -let - buildLinux = (args: (linuxManualConfig args).overrideAttrs ({ makeFlags, postInstall, passthru, ... }: { - inherit patches postPatch; - postInstall = '' - ${postInstall} - - ${additionalInstall} - ''; - 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|= ${buildPackages.kmod}/bin/depmod|' - ''; - installTargets = [ "dtbs" "zinstall" ]; - dontStrip = true; - - passthru = passthru // { - image = "vmlinuz-dtb"; - }; - })); - - configfile = stdenv.mkDerivation { - name = "android-asus-z00t-config-${modDirVersion}"; - inherit version; - inherit src patches postPatch; - nativeBuildInputs = [bison flex]; - - buildPhase = '' - echo "building config file" - cp -v ${./config-asus-z00t.aarch64} .config - yes "" | make $makeFlags "''${makeFlagsArray[@]}" oldconfig || : - ''; - - installPhase = '' - cp -v .config $out - ''; - }; - -in - -buildLinux { - inherit kernelPatches; - inherit src; - inherit version; - inherit modDirVersion; - inherit configfile; - stdenv = overrideCC stdenv buildPackages.gcc6; - - allowImportFromDerivation = true; -} +})