[Lessons Installing GrapheneOS with NixOS]
Installing GrapheneOS
I recently installed GrapheneOS on a new Pixel phone. Since NixOS is my daily driver, I had to search around a bit to figure out how to install the required tools as the official documentation only mentions Arch and Debian/Ubuntu.
I saw conflicting information on what was required but they both seem to accomplish the same thing. This is what I eventually did, based on this blog post (although I used the web installer, not the CLI installer):
First, I updated my system's udev rules. This stumped me for a bit, not understanding these need to go in services.udev.packages and not home.packages or environment.systemPackages:
services.udev.packages = with pkgs; [
android-udev-rules
]
Then the android-tools package was required, I installed it with home manager:
home.packages = with pkgs; [
android-tools
]
After that the installer started working and ran without issue.
Accidentally Learning Something
When I started writing this note, I found a second article which takes a different approach. I assumed they accomplish the same thing (getting GrapheneOS installed) but it wasn't clear why.
I did a bit of digging, looking at the adb "program" in nixpkgs. Up until this point, I seem to have taken for granted how these programs work. Turns out they're just nix modules maintained by individuals and shipped with nixpkgs.
Looking at the source for the programs.adb option in NixOS, I chuckled as I saw it doing the exact same as the above article:
config = lib.mkIf config.programs.adb.enable {
services.udev.packages = [ pkgs.android-udev-rules ];
environment.systemPackages = [ pkgs.android-tools ];
. . .
};
So I learned something about programs in NixOS. They're just opinionated ways of installing and configuring common software. I'd already been doing this with my own install to break things up and easily toggle systems on and off. Of course!