Skip to content

Commit f079afb

Browse files
authored
Merge pull request #236 from jaen/fix-python-tests
Fix Python tests
2 parents a667966 + 9ed6761 commit f079afb

30 files changed

+1037
-166
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ result
22
result-*
33

44
__pycache__
5+
.pytest_cache
6+
.mypy_cache
7+
.ruff_cache

flake.lock

Lines changed: 34 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33

44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
6+
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
7+
68
androidPkgs.url = "github:tadfisher/android-nixpkgs/stable";
9+
10+
flake-compat.url = "github:nix-community/flake-compat";
711
};
812

9-
outputs = { self, nixpkgs, androidPkgs, ... }@inputs: let
13+
outputs = { self, nixpkgs, nixpkgs-unstable, androidPkgs, flake-compat, ... }@inputs: let
1014
pkgs = import ./pkgs/default.nix { inherit inputs; };
1115
in {
1216
# robotnixSystem evaluates a robotnix configuration
@@ -24,6 +28,7 @@
2428

2529
packages.x86_64-linux = {
2630
manual = (import ./docs { inherit pkgs; }).manual;
31+
gitRepo = pkgs.gitRepo;
2732
};
2833

2934
devShell.x86_64-linux = pkgs.mkShell {

flake/compat.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{ system ? builtins.currentSystem }:
2+
let
3+
lock = builtins.fromJSON (builtins.readFile ./../flake.lock);
4+
flake-compat-entry = lock.nodes.root.inputs.flake-compat;
5+
6+
inherit (lock.nodes."${ flake-compat-entry }".locked) owner repo narHash;
7+
8+
flake-compat = builtins.fetchTarball {
9+
url = "https://github.com/${ owner }/${ repo }/archive/${ lock.nodes.flake-compat.locked.rev }.tar.gz";
10+
sha256 = narHash;
11+
};
12+
in
13+
import flake-compat {
14+
inherit system;
15+
16+
src = ./..;
17+
}

flavors/lineageos/test_lineageos_updater.py

Lines changed: 0 additions & 138 deletions
This file was deleted.

modules/envpackages.nix

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@ in
2929
nettools # Needed for "hostname" in build/soong/ui/build/sandbox_linux.go
3030
procps # Needed for "ps" in build/envsetup.sh
3131
]
32-
(mkIf (config.androidVersion >= 10) [
32+
(mkIf (config.androidVersion >= 12) [
33+
freetype # Needed by jdk9 prebuilt
34+
fontconfig
35+
36+
# Goldfish doesn't need py2 anymore in Android 12+!
37+
# c.f. https://android.googlesource.com/device/generic/goldfish/+/605e6a14e44c99e87d48bf52507f8aa01633fb04
38+
python3
39+
])
40+
(mkIf ((config.androidVersion >= 10) && (config.androidVersion <= 11)) [
3341
freetype # Needed by jdk9 prebuilt
3442
fontconfig
3543

modules/release.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ let
1212
jre = if (config.androidVersion >= 11) then pkgs.jdk11_headless else pkgs.jre8_headless;
1313
deps = with pkgs;
1414
[ otaTools openssl jre zip unzip pkgs.getopt which toybox vboot_reference util-linux
15-
python # ota_from_target_files invokes, brillo_update_payload which has "truncate_file" which invokes python
15+
# ota_from_target_files invokes, brillo_update_payload which has "truncate_file" which invokes python
16+
# c.f. https://android.googlesource.com/platform/system/update_engine/+/refs/heads/main/scripts/brillo_update_payload#338
17+
python3
1618
];
1719
in ''
1820
export PATH=${lib.makeBinPath deps}:$PATH

pkgs/default.nix

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
# SPDX-FileCopyrightText: 2020 Daniel Fullmer and robotnix contributors
22
# SPDX-License-Identifier: MIT
33

4-
{ inputs ? (import (
5-
fetchTarball {
6-
url = "https://github.com/edolstra/flake-compat/archive/12c64ca55c1014cdc1b16ed5a804aa8576601ff2.tar.gz";
7-
sha256 = "0jm6nzb83wa6ai17ly9fzpqc40wg1viib8klq8lby54agpl213w5"; }
8-
) {
9-
src = ../.;
10-
}).defaultNix.inputs,
11-
... }@args:
4+
{
5+
system ? builtins.currentSystem,
6+
inputs ? (import ../flake/compat.nix { inherit system; }).defaultNix.inputs,
7+
...
8+
}@args:
129

1310
let
1411
inherit (inputs) nixpkgs androidPkgs;
@@ -17,5 +14,5 @@ in nixpkgs.legacyPackages.x86_64-linux.appendOverlays [
1714
androidPkgs.packages = androidPkgs.packages.x86_64-linux;
1815
androidPkgs.sdk = androidPkgs.sdk.x86_64-linux;
1916
})
20-
(import ./overlay.nix)
17+
(import ./overlay.nix { inherit inputs; })
2118
]

pkgs/gitRepo/default.nix

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{ lib, inputs, fetchFromGitHub, rsync, git, gnupg, less, openssh, ... }:
2+
let
3+
inherit (inputs) nixpkgs-unstable;
4+
5+
unstablePkgs = nixpkgs-unstable.legacyPackages.x86_64-linux;
6+
in
7+
unstablePkgs.gitRepo.overrideAttrs(oldAttrs: rec {
8+
version = "2.45";
9+
10+
src = fetchFromGitHub {
11+
owner = "android";
12+
repo = "tools_repo";
13+
rev = "v${ version }";
14+
hash = "sha256-f765TcOHL8wdPa9qSmGegofjCXx1tF/K5bRQnYQcYVc=";
15+
};
16+
17+
nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [ rsync git ];
18+
19+
repo2nixPatches = ./patches;
20+
21+
# NOTE: why `git apply` instead of relying on `patches`? For some reason when
22+
# using `patches` the source `rsync`ed into `var/repo` is missing those changes
23+
installPhase = ''
24+
runHook preInstall
25+
26+
mkdir -p var/repo
27+
rsync -a $src/ var/repo/
28+
29+
(
30+
export GIT_CONFIG_GLOBAL=$TMPDIR/.gitconfig
31+
export GIT_CONFIG_NOSYSTEM=true
32+
33+
cd var/repo
34+
35+
git config --global --add safe.directory "$PWD"
36+
git config --global user.email "nemo@nix"
37+
git config --global user.name "Nemo Nix"
38+
39+
chmod +w -R .
40+
41+
git init
42+
git add -A
43+
git commit -m "Upstream sources"
44+
45+
git am $repo2nixPatches/*.patch
46+
47+
git log -n 1 --format="%H" > ../../COMMITED_REPO_REV
48+
)
49+
50+
mkdir -p $out/var/repo
51+
mkdir -p $out/bin
52+
53+
rsync -a var/repo/ $out/var/repo/
54+
55+
# Copying instead of symlinking to the above directory is necessary, because otherwise
56+
# running `repo init` fails, as I assume the script gets confused by being located in
57+
# a git repo itself
58+
cp repo $out/bin/repo
59+
60+
runHook postInstall
61+
'';
62+
63+
# Specify the patched checkout as the default version of repo
64+
postFixup = ''
65+
wrapProgram "$out/bin/repo" \
66+
--set REPO_URL "file://$out/var/repo" \
67+
--set REPO_REV "$(cat ./COMMITED_REPO_REV)" \
68+
--prefix PATH ":" "${ lib.makeBinPath [ git gnupg less openssh ] }"
69+
'';
70+
})

0 commit comments

Comments
 (0)