Robotnix -- build Android (AOSP) using Nix

Robotnix is a project which aims to make building Android ROMs as easy as running nix-build. For example:

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

After waiting for a very long time, this will produce an image which can be flashed onto a Pixel 3 XL phone (crosshatch) using fastboot.

For now, I have been focusing on Pixel devices, which receive monthly security updates from Google. Robotnix uses a NixOS-style module system to configure various aspects of the build, and includes modules providing support for vanilla AOSP, GrapheneOS, Chromium/Bromite/Vanadium webview, MicroG, seamless OTA updates, signed builds with verified boot, etc. See the repository for additional information.

My daily driver has been running a robotnix-built Android for almost a year, and I intend to keep up to date with Google’s monthly updates for the foreseeable future. In the past, it has produced working builds for Pixel XL, Pixel 2, and Pixel 3 XL phones. I am open to extending the codebase in generic ways to potentially handle other phones and different source repos, if there is enough developer interest.

Special thanks to @ajs124’s NixDroid, upon which Robotnix was initially based. Also thanks to @samueldr for Pixel 2 testing. Robotnix can be thought of as an interim solution until we reach “nix singularity” with Mobile NixOS. :smile:

24 Likes

I have some good follow-up news on the project:

Robotnix has been accepted to receive funding from NLNet through their NGI Zero grant program. With this funding, we aim to improve the project with a focus on in a few main areas:

  1. Creating development / build infrastructure
  2. Improving Robotnix usability
  3. Leveraging Robotnix to build additional Android-related projects

This funded effort should last through a good portion of the remainder of this year. In the near-term (coming weeks/months), I intend to work on improving Robotnix documentation, creating automated build / test infrastructure, and producing “reproducibility reports” for Robotnix-built Android. @ajs124 will also be contributing to certain upcoming milestones, specifically, improving LineageOS support and developing an optional module to include certain Google apps.

I’m excited for the opportunity to be able to commit additional time to work on this project, and I’m very grateful to NLNet for their support.

This is also a good opportunity to plug the newly created IRC channel. Come by and ask any questions you might have at #robotnix on Freenode.

11 Likes

Please consider GitHub - numtide/devshell: Per project developer environments for the first point (development infrastructure part). And GitHub - divnix/digga: A flake utility library to craft shell-, home-, and hosts- environments. for the second.

Is anyone still working with Robotnix? I’ve been wanting to find a good base for a port of pikvm.org to a handheld phone. And enabling root / so we can use the USB port as keyboard, mouse, disk, network, etc is key.

Robotnix seems like a decent base / starting approach to that.

1 Like

I’m still working on it but it’s been on and off.

I still run LineageOS+fdroid+µG built using Robotnix on my daily driver phone and have been maintaining the components requried for that stack to work but not nearly as well as I’d like.
Updates are infrequent and sporadic, depending on when I have time and motivation to perform and test them. It’s been a bit better in recent months but I don’t know whether that will continue.

I’ve actually written about the current status of Robotnix’ major components in the README:

Quite recently, there’s been an uptick in interest in Robotnix again. Two people started contributing maintenance patches this year and I recently met someone IRL who expressed interest in making Robotnix a thing again because they had like 10 ideas for stupid Android things they’d like to patch out of their phone :D.

Besides maintenance, there hasn’t been any real feature work in quite some time. The most significant work that happened in the past years were major LineageOS version bumps.
I have recently gotten a bit of motivation to work on some things but, again, I cannot tell whether that continues.

There’s still some quite essential maintenance/feature work that hasn’t been done at all such as providing a working webview. The from-source chromium build has been broken for a while and I haven’t gotten around to ripping that out and replacing it with easier to maintain prebuilts. You need to patch one in using Magisk at runtime currently.

As for your use-case, I’d start by making all of that work in a regular non-robotnix AOSP/LineageOS build first and then porting it to robotnix.

You see, like most derivations in Nixpkgs too, robotnix is mostly “just” a wrapper around the regular old AOSP build process; making it run inside a Nix derivation. We then do provide additional components that integrate with the AOSP build process but are configurable in Nix via a nicely abstracted module system. For a component to be configurable via Nix, it needs to work in the first place though and that’s where I see the primary difficulty in what you have described.

2 Likes