I like the usability and discoverability of Termux (unprivileged Linux distro targeting Android), but the idea of painfully recreating a distro with Android toolchain / bionic sounds horrible. I felt like the flexibility of Nix would save the day the best way ever, and yesterday I finally bought an aarch64 tablet to give it a go.
Sorry if this is common knowledge, but I couldn’t find a guide or a script anywhere and cobbled my own one.
Limitations: requires Termux, relies on proot pseudo-bind-mounts, only works on aarch64 (and maybe x86).
Pros: does not require root, user namespaces or disabling SELinux. Also, it frigging works!
Run it with nix-in-termux nix run nixpkgs.bashInteractive or another nix subcommand
UPDATE 1: I’ve started something even better, a separate app bringing Nix to your device without relying on Termux the distro. Test builds here: https://nix-on-droid.unboiled.info
I tried again and it seems to work with nix-on-droid-install.
I installed a couple of applications with home-manager but I don’t seem to run some of them. I installed tealdeer (tldr) and exa and I get ‘command not found’ when I try to run them.
Oh, wow, an x86 request. Nix-on-Droid doesn’t have a x86 bootstrap zip yet, and while it’s not that difficult to create one, I kinda doubt that it’s useful for your particular setup.
You see, most of the magic is there to make it work under regular android app restrictions. Your use case sounds like you don’t care about this at all, you have root and you want to run nix-managed stuff as root, which is possible, but difficult. For you it’s probably better to just try and install nix directly on top of Android, unpacking a Nix tarball into / and executing nix from there, like this person did with guix: Guix on Android! — 2018 — Blog — GNU Guix
I don’t suppose there’s some android equivalent of sudo that would make your style of things easy? I don’t know why running nix manager stuff as root on android would be difficult. It’s probably easier for me to use your thing rebuilt for x86 than to figure out how this all works (though that might be inevitable anyway…)
I’m not aware of anything other than Android’s su. You can run su in a fallback session, and then run /…/usr/bin/login as root. But I don’t know any way to become root from within Nix-on-Droid env. If you solve it, let me know in https://github.com/t184256/nix-on-droid-bootstrap/issues/3
Hey, thanks! I tried running the apk but it says could not open or something like that. I’ve too much on my plate to work on this today, just leaving a note in case it’s not my fault.
Edit: Oh, running the app that seems to be some sort of installer, worked, results in something like “process exited error code 1”.
I’m on the androidx86 image.
Sorry for being vague, will try to get back to you properly later.
Hello!
I literally signed up here because of your post. I’m -needless to say- interested in reading/hearing anything or Anything you feel comfortable sharing about your journey to get to this (non-Termux environment), along with any advice for someone JUST LIKE YOURSELF, with similar goals.
THANK YOU!
YOU can also reach me at zefon@zefdroid.com, my admin email address.