You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Daniel Fullmer ec6335c91b Exit github CI based on number of failures 2 days ago
.github/workflows Exit github CI based on number of failures 2 days ago
LICENSES creating licenses directory 12 months ago
apks vanadium: 97.0.4692.70 -> 97.0.4692.87 1 week ago
docs More easily build individual android components 4 days ago
flavors lineageos: 19.0 init 4 days ago
lib lib: Fix dimen resource type typo 4 months ago
modules More easily build individual android components 4 days ago
nixos Update nixpkgs to 21.11 2 months ago
pkgs fetchgit: synchronize changes with nixos-21.11 2 months ago
scripts scripts/patchelf-prefix: remove debugging messages 2 months ago
sdk vanilla: split configurations by androidVersion 5 months ago
template Fix documentated usage of keyStorePath 8 months ago
tests source: use "mkdir -p" 8 months ago
.flake8 Add mypy / flake8 checks for python files 6 months ago
.gitignore Add basic test for mk_repo_file.py 6 months ago
NEWS.md NEWS.md: update for 2022-01-08 2 weeks ago
README.md Various small updates to documentation 3 months ago
build.sh Shellcheck scripts 6 months ago
check.nix Move IFD expressions to checks.nix 2 days ago
components.json More easily build individual android components 4 days ago
components.nix More easily build individual android components 4 days ago
configs.nix Reorganize release.nix 2 days ago
default.nix Provide recoveryImg output 2 weeks ago
example.nix Removed flaky Google module 8 months ago
flake.lock Update nixpkgs to 21.11 2 months ago
flake.nix Update nixpkgs to 21.11 2 months ago
mypy.ini Add mypy / flake8 checks for python files 6 months ago
ota.nix Fix documentated usage of keyStorePath 8 months ago
release.nix Move IFD expressions to checks.nix 2 days ago
shell.nix Replace our custom solution with flake-compat 4 months ago

README.md

robotnix - Build Android (AOSP) using Nix

Robotnix enables a user to easily and reliably build Android (AOSP) images using the Nix package manager / build tool.

Quick Start

Here is a single command to build an img which can be flashed onto a Pixel 3 XL (crosshatch).

$ nix-build "https://github.com/danielfullmer/robotnix/archive/master.tar.gz" \
    --arg configuration '{ device="crosshatch"; flavor="vanilla"; }' \
    -A img

The command above will build an image signed with publicly known test-keys, so definitely don't use this for anything intended to be secure. To flash the result to your device, run fastboot update -w <img.zip>.

Motivation

Android projects often contain long and complicated build instructions requiring a variety of tools for fetching source code and executing the build. This applies not only to Android itself, but also to projects included in the Android build, such as the Linux kernel, Chromium webview, MicroG, other external/prebuilt privileged apps, etc. Robotnix orchestrates the diverse build systems across these multiple projects using Nix, inheriting its reliability and reproducibility benefits, and consequently making the build and signing process very simple for an end-user.

Robotnix includes a NixOS-style module system which allows users to easily customize various aspects of the their builds. Some optional modules include:

Documentation

More detailed robotnix documentation is available at https://docs.robotnix.org, and should be consulted before use.

Robotnix was presented at Nixcon 2020, and a recording of the talk is available here. Slides for the talk are also available here.

Requirements

The AOSP project recommends at least 250GB free disk space as well as 16GB RAM. (Certain device kernels which use LTO+CFI may require even more memory) A typical build requires approximately 45GB free disk space to check out the android source, ~14GB for chromium, plus ~100GB of additional free space for intermediate build products. By default, Nix uses /tmp to store these intermediate build products, so ensure your /tmp is not mounted using tmpfs, since the intermediate builds products are very large and will easily use all of your RAM (even if you have 32GB)! A user can use the --cores option for nix-build to set the number of cores to use, which can also be useful to decrease parallelism in case memory usage of certain build steps is too large.

Robotnix also requires support for user namespaces (CONFIG_USER_NS Linux kernel option). Currently, using the "signing inside Nix with a sandbox exception" feature also requires a Nix daemon with the sandbox support enabled. This feature is currently not supported inside Docker for this reason.

A full Android 10 build with Chromium webview takes approximately 10 hours on my quad-core i7-3770 with 16GB of memory. AOSP takes approximately 4 hours of that, while webview takes approximately 6 hours. I have recently upgraded to a 3970x Threadripper with 32-cores. This can build chromium+android in about an hour.

Community

The #robotnix:nixos.org channel on Matrix is available for a place to chat about the project, ask questions, and discuss robotnix development. You can easily join the channel using the Element web client via this link.

Donating to robotnix

If you find robotnix helpful, please consider donating to the project. Especially consider making a donation if you rely on regular robotnix updates for your personal device. Donations will be used to support ongoing Android updates, developer hardware and build infrastructure, as well as future improvements. Your support is greatly appreciated.

  • My GitHub sponsors page is here.
  • Paypal donations may be made using this link.
  • Bitcoin donations may be directed toward 3GEtqfkPkSSrRFpdcfy4T6YALgTwRyufip.

License information

This project is available as open source under the terms of MIT license. However, for accurate information, please check individual files.