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!
Install and launch Termux
Download the script: https://github.com/t184256/nix-in-termux/raw/master/nix-in-termux
Read the script
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