Vanilla Mobile Nixos - Run standard NixOS on your mobile devices!

One of my missions at NixCon last year was to convince people to put regular NixOS on their phones. The problem was that at the time, there was no easy way to do it.
Vanilla Mobile NixOS provides everything needed to run standard NixOS on (supported) mobile devices.

There’s only so much I can do on my own given my single device and limited time, but this should be helpful even for yet to be supported devices. I hope that we can keep pushing mobile Linux and mobile NixOS forward together.
Let me know if you have any questions or want to help!

Vanilla Mobile NixOS

Everything you need to run standard NixOS on a mobile device.
See device support below. Contributions welcome.

Why run NixOS on a mobile device?

NixOS’s declarative configuration shines best when used with multiple devices. Being able to use the same workflows, integrations, and software you’ve already configured can be a huge benefit.

In a more general sense, freedom on mobile devices is in danger. It’s more dire than Windows and a place that Linux can similarly help. It’s natural to point out the potential problems and rough edges with mobile Linux, but just like the switch from Windows to Linux, it keeps getting better. What’s needed are more passionate people like probably you, a NixOS user.

What does “Vanilla” mean?

It means installing NixOS on the device using a standard initramfs and bootloader. Some of the advantages to this over how mobile-nixos usually works are switching kernels without reflashing and keeping things simpler and closer to a desktop config. This is made possible on Android based devices by using U-Boot. Some awesome work has been done on U-Boot to allow going from the Android bootloader to a UEFI environment.

What devices are supported?

See What devices are supported?.

What software should I use?

Depending on your tastes, it’s possible to keep your mobile config 95% identical to your desktop config or completely custom. See docs/software-info.md for specific details and instructions.

Installation Instructions

See the instructions linked in the devices list.

Acknowledgements

  • postmarketOS. Their community is doing incredible work continually pushing things forward for everyone.
  • chayleaf. They made a detailed blog post on doing this with their OnePlus 6 that I wish I found sooner.
26 Likes

This is theoretically awesome. Thank you for sharing. So many a Nixer would want this. Of course, many would be concerned about whether and which Android apps would work, because most of us rely on them. Will my bank’s app be supported? Public transport apps, government apps…

But this is not Android, right? So no apps will work? You will instead have NixOS in your pocket

I think he means android apps with waydroid. (If the chip is arm the arm apks can work.) I am pretty sure that all the apps that need secure something like banking etc. will not work like this.

There are projects like android_translation_layer / Android Translation Layer · GitLab and Waydroid, but I personally only use native Linux apps. That works for me, since I do browser only banking, but I can understand the potential issues for others. I’ve seen some open source public transit apps before, but those are obviously area specific.
We have to try push things in a better direction even with stuff like Android Smartscreen existing, though. In that sense, Android based projects like Graphene OS are in the same position.

2 Likes

Hi, it’s always nice to see NixOS run on more hardware, especially on mobile devices! Would you like to compare this with the GitHub - mobile-nixos/mobile-nixos: 📱 (rebooting... please wait...) · GitHub project? It seems that both are trying to “port” NixOS to mobile devices.

Also, what work can possibly be shared across these two projects?

1 Like

The first difference is this from the post:

What does “Vanilla” mean?

It means installing NixOS on the device using a standard initramfs and bootloader. Some of the advantages to this over how mobile-nixos usually works are switching kernels without reflashing and keeping things simpler and closer to a desktop config. This is made possible on Android based devices by using U-Boot. Some awesome work has been done on U-Boot to allow going from the Android bootloader to a UEFI environment.

Mobile NixOS:

  • Has a custom initramfs and doesn’t usually use U-Boot. That was necessary in the past and still likely allows it to support devices Vanilla Mobile NixOS couldn’t yet.
  • Due to above, upgrading kernels requires re-flashing the phone.
  • Uses a custom system for building images. Vanilla Mobile NixOS uses Disko.
  • Is more mature with more devices but also out of date.
  • Has a custom kernel building/configuring system and differing methodology (Vanilla Mobile NixOS extends the regular NixOS kernel with extra patches and config).
  • Doesn’t have a cache.
  • Has a custom system for debugging over USB and stage 1 recovery. Vanilla Mobile NixOS uses usb-moded like PostMarketOS and SailfishOS for switching USB gadget modes. I haven’t added it to stage 1 yet, but that wouldn’t be hard.
  • Mostly doesn’t include what software is used in its scope of documentation and modules.
  • Due to above doesn’t have some stuff like modules for mobile-config-firefox, wvkbd, sleep inhibitors, ect.
  • Doesn’t have explicit support/examples for using standalone compositors like Hyprland.
  • Is complicated with a lot of non-Nix code.

I’m quite far removed from it at this point and never fully used it, so I can’t give a full comparison. The key difference is “Vanilla”. This project is trying to be close to a NixOS desktop in terms of how the project is structured and installed.

Also, what work can possibly be shared across these two projects?

There is much I referenced in Mobile NixOS and stuff here Mobile NixOS could adopt (swclock-offset for example), but what I’d really like is for as much to get upstreamed as possible.

Overall, Mobile NixOS is the OG, and the developer is far more qualified than me. It’s just that there are ways of doing things now that didn’t exist before that I think are the way forward.
I also really want to make things easy/work well. That’s why stuff like a cache was mandatory for me despite the extra security overhead.

Please correct me @samueldr if I got anything wrong, and thank you so much for all your work both for mobile and otherwise.

7 Likes

What are the chances this would work on an old Pinephone/Pinephone Pro? I have one of each bouncing around here that I absolutely can’t make work as a phone (work requires things like Okta Verify) but which could make nice little pocket NixOS boxen.

I don’t see why not. There are some differences from Android devices, but nothing crazy. I’m happy to help if you want to try adding support for one or both of those devices.

NixOS on Pinephone and Pinephone Pro (PPP) is not exceptionally difficult. Both devices will require you to flash u-boot to a specific disk sector, after which the stock NixOS kernel and userspace will get you to a system with display/touch and some limited networking (e.g. USB-C ↔ ethernet adapter).

for actual use (mainline Linux on PPP lacks working audio and battery charging, neither phone supports WiFi OOTB) you can either cherry-pick some kernel patches from the postmarketOS tree – same way junestepp’s done with sdm845 i think – or if you hate long build times just build the missing kernel modules and device trees out-of-tree.

here’s a few points to reference:

the #nixos-on-arm:nixos.org Matrix channel is where you’ll find the most people doing similar things, i expect.