Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python tests #236

Merged
merged 6 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ result
result-*

__pycache__
.pytest_cache
.mypy_cache
.ruff_cache
35 changes: 34 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";

androidPkgs.url = "github:tadfisher/android-nixpkgs/stable";

flake-compat.url = "github:nix-community/flake-compat";
};

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

packages.x86_64-linux = {
manual = (import ./docs { inherit pkgs; }).manual;
gitRepo = pkgs.gitRepo;
};

devShell.x86_64-linux = pkgs.mkShell {
Expand Down
17 changes: 17 additions & 0 deletions flake/compat.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ system ? builtins.currentSystem }:
let
lock = builtins.fromJSON (builtins.readFile ./../flake.lock);
flake-compat-entry = lock.nodes.root.inputs.flake-compat;

inherit (lock.nodes."${ flake-compat-entry }".locked) owner repo narHash;

flake-compat = builtins.fetchTarball {
url = "https://github.com/${ owner }/${ repo }/archive/${ lock.nodes.flake-compat.locked.rev }.tar.gz";
sha256 = narHash;
};
in
import flake-compat {
inherit system;

src = ./..;
}
138 changes: 0 additions & 138 deletions flavors/lineageos/test_lineageos_updater.py

This file was deleted.

10 changes: 9 additions & 1 deletion modules/envpackages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ 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

# Goldfish doesn't need py2 anymore in Android 12+!
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay not 100% sure how to trace this commit to Android version, but I think that's right

# c.f. https://android.googlesource.com/device/generic/goldfish/+/605e6a14e44c99e87d48bf52507f8aa01633fb04
python3
])
(mkIf ((config.androidVersion >= 10) && (config.androidVersion <= 11)) [
freetype # Needed by jdk9 prebuilt
fontconfig

Expand Down
4 changes: 3 additions & 1 deletion modules/release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 6 additions & 9 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# SPDX-FileCopyrightText: 2020 Daniel Fullmer and robotnix contributors
# SPDX-License-Identifier: MIT

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

let
inherit (inputs) nixpkgs androidPkgs;
Expand All @@ -17,5 +14,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; })
]
70 changes: 70 additions & 0 deletions pkgs/gitRepo/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{ lib, inputs, fetchFromGitHub, rsync, git, gnupg, less, openssh, ... }:
let
inherit (inputs) nixpkgs-unstable;

unstablePkgs = nixpkgs-unstable.legacyPackages.x86_64-linux;
in
unstablePkgs.gitRepo.overrideAttrs(oldAttrs: rec {
version = "2.45";

src = fetchFromGitHub {
owner = "android";
repo = "tools_repo";
rev = "v${ version }";
hash = "sha256-f765TcOHL8wdPa9qSmGegofjCXx1tF/K5bRQnYQcYVc=";
};

nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [ rsync git ];

repo2nixPatches = ./patches;

# NOTE: why `git apply` instead of relying on `patches`? For some reason when
# using `patches` the source `rsync`ed into `var/repo` is missing those changes
installPhase = ''
runHook preInstall

mkdir -p var/repo
rsync -a $src/ var/repo/

(
export GIT_CONFIG_GLOBAL=$TMPDIR/.gitconfig
export GIT_CONFIG_NOSYSTEM=true

cd var/repo

git config --global --add safe.directory "$PWD"
git config --global user.email "nemo@nix"
git config --global user.name "Nemo Nix"

chmod +w -R .

git init
git add -A
git commit -m "Upstream sources"

git am $repo2nixPatches/*.patch

git log -n 1 --format="%H" > ../../COMMITED_REPO_REV
)

mkdir -p $out/var/repo
mkdir -p $out/bin

rsync -a var/repo/ $out/var/repo/

# Copying instead of symlinking to the above directory is necessary, because otherwise
# running `repo init` fails, as I assume the script gets confused by being located in
# a git repo itself
cp repo $out/bin/repo

runHook postInstall
'';

# Specify the patched checkout as the default version of repo
postFixup = ''
wrapProgram "$out/bin/repo" \
--set REPO_URL "file://$out/var/repo" \
--set REPO_REV "$(cat ./COMMITED_REPO_REV)" \
--prefix PATH ":" "${ lib.makeBinPath [ git gnupg less openssh ] }"
'';
})
Loading