From 285d307fe585a7904a1455314a8926cc295820f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20Ma=C5=84ko?= Date: Sat, 25 May 2024 00:52:21 +0200 Subject: [PATCH] Some more improvements --- flake.lock | 19 ++- flake.nix | 3 +- flavors/lineageos/test_lineageos_updater.py | 149 -------------------- modules/envpackages.nix | 8 +- modules/release.nix | 4 +- pkgs/default.nix | 6 +- pkgs/overlay.nix | 8 ++ scripts/mk_repo_file.py | 1 + 8 files changed, 42 insertions(+), 156 deletions(-) delete mode 100644 flavors/lineageos/test_lineageos_updater.py diff --git a/flake.lock b/flake.lock index edb64697..794d9aa2 100644 --- a/flake.lock +++ b/flake.lock @@ -95,6 +95,22 @@ "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1716330097, + "narHash": "sha256-8BO3B7e3BiyIDsaKA0tY8O88rClYRTjvAp66y+VBUeU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5710852ba686cc1fd0d3b8e22b3117d43ba374c2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1711668574, @@ -114,7 +130,8 @@ "root": { "inputs": { "androidPkgs": "androidPkgs", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_2", + "nixpkgs-unstable": "nixpkgs-unstable" } }, "systems": { diff --git a/flake.nix b/flake.nix index 368b9b48..99b561ae 100644 --- a/flake.nix +++ b/flake.nix @@ -3,10 +3,11 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; androidPkgs.url = "github:tadfisher/android-nixpkgs/stable"; }; - outputs = { self, nixpkgs, androidPkgs, ... }@inputs: let + outputs = { self, nixpkgs, nixpkgs-unstable, androidPkgs, ... }@inputs: let pkgs = import ./pkgs/default.nix { inherit inputs; }; in { # robotnixSystem evaluates a robotnix configuration diff --git a/flavors/lineageos/test_lineageos_updater.py b/flavors/lineageos/test_lineageos_updater.py deleted file mode 100644 index b114257b..00000000 --- a/flavors/lineageos/test_lineageos_updater.py +++ /dev/null @@ -1,149 +0,0 @@ -# SPDX-FileCopyrightText: 2021 Daniel Fullmer and robotnix contributors -# SPDX-License-Identifier: MIT - -from unittest.mock import patch -from typing import Any -import subprocess -import textwrap - -import update_device_metadata -import update_device_dirs - - -def test_fetch_metadata(tmp_path: Any) -> None: - lineage_build_targets = tmp_path / "lineage-build-targets" - lineage_build_targets.write_text(textwrap.dedent(''' - # Ignore comments - crosshatch userdebug lineage-18.1 W - ''')) - - devices_json = tmp_path / "devices.json" - devices_json.write_text(textwrap.dedent(''' - [ - { "model": "crosshatch", "oem": "Google", "name": "Pixel 3 XL", "lineage_recovery": true} - ] - ''')) - - # nix-prefetch-git that is used underneath seems to require a real git repo - subprocess.check_output(["git", "init", "--initial-branch=main"], cwd=tmp_path) - subprocess.check_output(["git", "add", "-A"], cwd=tmp_path) - subprocess.check_output(["git", "commit", "-am", "Initial commit"], cwd=tmp_path) - - metadata = update_device_metadata.fetch_metadata( - f"file://{tmp_path}", - "lineage-build-targets", - "devices.json" - ) - - assert metadata == { - "crosshatch": { - "branch": "lineage-18.1", - "lineage_recovery": True, - "name": "Pixel 3 XL", - "variant": "userdebug", - "vendor": "google" - }, - } - - -@patch("update_device_dirs.checkout_git") -@patch("update_device_dirs.ls_remote") -def test_fetch_device_dirs(ls_remote: Any, checkout_git: Any, tmpdir: Any) -> None: - baseurl = 'BASEURL' - - ls_remote_dict = { - f'{baseurl}/android_device_google_crosshatch': {'refs/heads/lineage-18.1': '12345'}, - f'{baseurl}/android_kernel_google_msm-4.9': {'refs/heads/lineage-18.1': '67890'} - } - ls_remote.side_effect = lambda url: ls_remote_dict[url] - - fake_dir = tmpdir.mkdir('android_device_google_crosshatch') - (fake_dir / "lineage.dependencies").write( - '''[ - { - "repository": "android_kernel_google_msm-4.9", - "target_path": "kernel/google/msm-4.9" - } - ]''' - ) - checkout_git_dict = { - (f'{baseurl}/android_device_google_crosshatch', 'refs/heads/lineage-18.1'): - { - "date": "2021-07-12T10:07:57-05:00", - "deepClone": False, - "deps": [ - "packages/apps/ElmyraService" - ], - "fetchSubmodules": False, - "leaveDotGit": False, - "path": fake_dir, - "rev": "0000000000ca33df352b45a4241c353b6a52ec7d", - "sha256": "00000000000aamp6w094ingaccr9cx6d6zi1wb9crmh4r7b19b1f", - "url": f"{baseurl}/android_device_google_crosshatch" - }, - (f'{baseurl}/android_kernel_google_msm-4.9', 'refs/heads/lineage-18.1'): - { - "date": "2021-07-12T10:07:57-05:00", - "deepClone": False, - "fetchSubmodules": False, - "leaveDotGit": False, - "path": tmpdir.mkdir('empty'), - "rev": "0000000000ca33df352b45a4241c353b6a52ec7d", - "sha256": "00000000000aamp6w094ingaccr9cx6d6zi1wb9crmh4r7b19b1f", - "url": f"{baseurl}/android_kernel_google_msm-4.9" - }, - } - checkout_git.side_effect = lambda url, rev: checkout_git_dict[url, rev] - - metadata = { - "crosshatch": { - "branch": "lineage-18.1", - "lineage_recovery": True, - "name": "Pixel 3 XL", - "variant": "userdebug", - "vendor": "google" - }, - } - dirs = update_device_dirs.fetch_device_dirs(metadata, baseurl, 'lineage-18.1') - - assert 'device/google/crosshatch' in dirs - - -@patch("update_device_dirs.checkout_git") -@patch("update_device_dirs.ls_remote") -def test_fetch_vendor_dirs(ls_remote: Any, checkout_git: Any, tmpdir: Any) -> None: - baseurl = 'BASEURL' - ls_remote_dict = { - 'BASEURL/proprietary_vendor_google': {'refs/heads/lineage-18.1': '12345'}, - } - ls_remote.side_effect = lambda url: ls_remote_dict[url] - - checkout_git_dict = { - ('BASEURL/proprietary_vendor_google', 'refs/heads/lineage-18.1'): - { - "date": "2021-07-12T10:07:57-05:00", - "deepClone": False, - "fetchSubmodules": False, - "leaveDotGit": False, - "path": 'foobar', - "rev": "0000000000ca33df352b45a4241c353b6a52ec7d", - "sha256": "00000000000aamp6w094ingaccr9cx6d6zi1wb9crmh4r7b19b1f", - "url": "BASEURL/proprietary_vendor_google" - }, - } - checkout_git.side_effect = lambda url, rev: checkout_git_dict[url, rev] - - metadata = { - "crosshatch": { - "branch": "lineage-18.1", - "lineage_recovery": True, - "name": "Pixel 3 XL", - "variant": "userdebug", - "vendor": "google" - }, - } - dirs = update_device_dirs.fetch_vendor_dirs( - metadata, baseurl, 'lineage-18.1', 'lineage-18.1', {} - ) - - assert 'vendor/google' in dirs diff --git a/modules/envpackages.nix b/modules/envpackages.nix index 25d93e94..32d8eb79 100644 --- a/modules/envpackages.nix +++ b/modules/envpackages.nix @@ -29,7 +29,13 @@ in nettools # Needed for "hostname" in build/soong/ui/build/sandbox_linux.go procps # Needed for "ps" in build/envsetup.sh ] - (mkIf (config.androidVersion >= 10) [ + (mkIf (config.androidVersion >= 12) [ + freetype # Needed by jdk9 prebuilt + fontconfig + + python3 # glodfish doesn't need py2 anymore in Android 12+! + ]) + (mkIf ((config.androidVersion >= 10) && (config.androidVersion <= 11)) [ freetype # Needed by jdk9 prebuilt fontconfig diff --git a/modules/release.nix b/modules/release.nix index e570d752..782677cb 100644 --- a/modules/release.nix +++ b/modules/release.nix @@ -12,7 +12,9 @@ let jre = if (config.androidVersion >= 11) then pkgs.jdk11_headless else pkgs.jre8_headless; deps = with pkgs; [ otaTools openssl jre zip unzip pkgs.getopt which toybox vboot_reference util-linux - python # ota_from_target_files invokes, brillo_update_payload which has "truncate_file" which invokes python + # ota_from_target_files invokes, brillo_update_payload which has "truncate_file" which invokes python + # c.f. https://android.googlesource.com/platform/system/update_engine/+/refs/heads/main/scripts/brillo_update_payload#338 + python3 ]; in '' export PATH=${lib.makeBinPath deps}:$PATH diff --git a/pkgs/default.nix b/pkgs/default.nix index 9851c663..afcef3ad 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -3,8 +3,8 @@ { inputs ? (import ( fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/12c64ca55c1014cdc1b16ed5a804aa8576601ff2.tar.gz"; - sha256 = "0jm6nzb83wa6ai17ly9fzpqc40wg1viib8klq8lby54agpl213w5"; } + url = "https://github.com/nix-community/flake-compat/archive/8bf105319d44f6b9f0d764efa4fdef9f1cc9ba1c.tar.gz"; + sha256 = "sha256:0b1vcbficjcrdyqzn4pbb63xwjch1056nmjyyhk4p7kdskhl3nlj"; } ) { src = ../.; }).defaultNix.inputs, @@ -17,5 +17,5 @@ in nixpkgs.legacyPackages.x86_64-linux.appendOverlays [ androidPkgs.packages = androidPkgs.packages.x86_64-linux; androidPkgs.sdk = androidPkgs.sdk.x86_64-linux; }) - (import ./overlay.nix) + (import ./overlay.nix { inherit inputs; }) ] diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix index c2aba7ad..36282f7b 100644 --- a/pkgs/overlay.nix +++ b/pkgs/overlay.nix @@ -1,3 +1,9 @@ +{ inputs }: +let + inherit (inputs) nixpkgs-unstable; + + unstablePkgs = nixpkgs-unstable.legacyPackages.x86_64-linux; +in self: super: { android-emulator = super.callPackage ./android-emulator {}; @@ -33,6 +39,8 @@ self: super: { }); nix-prefetch-git = super.callPackage ./fetchgit/nix-prefetch-git.nix {}; + gitRepo = unstablePkgs.gitRepo; + ### # Robotnix helper derivations diff --git a/scripts/mk_repo_file.py b/scripts/mk_repo_file.py index 4927243b..53fda9dd 100755 --- a/scripts/mk_repo_file.py +++ b/scripts/mk_repo_file.py @@ -21,6 +21,7 @@ REPO_FLAGS = [ "--quiet", + # Based on v2.45, matching the one overlayed in pkgs "--repo-url=https://github.com/jaen/tools_repo", "--repo-rev=dca531f6d6e9fdcf00aa9d18f0153bd66a2e32ea", "--no-repo-verify",