Open Atemu opened 2 years ago
Related: Nix-on-Droid
It runs in Termux and I think it uses proot. No idea whether it bundles a nix-daemon.
GitHub: https://github.com/t184256/nix-on-droid Prebuilt APKs: https://nix-on-droid.unboiled.info/ F-Droid: https://f-droid.org/en/packages/com.termux.nix/
There are ways of using Nix on Android (nix-on-droid) but they're very limited (...)
You can install nix on any rom with
unset LD_PRELOAD
export USER=$(id -un) HOME=$PWD GROUP=$(id -g)
sudo mount -o remount,rw /
# do the same for /etc but the specifics vary, mines on tmpfs but only from android 11 and up
sudo mkdir /nix /data/nix
sudo mount -o bind /data/nix /nix
sudo chown $(id -u):$(id -g) -R /nix
# create /etc/resolv.conf however you want, i recommend
su
echo "nameserver 8.8.8.8" > /etc/resolv.conf
exit
# remount all back to ro
curl -L https://nixos.org/nix/install | sh
# then to get into the default nix profile
. nix-profile/etc/profile.d/nix.sh
# also the environment variable edits must be done before sourcing nix.sh or it will silently do nothing
should be all. from here install home manager as normal
install nix on any rom
sudo
Yeah, I don't think so.
Well im assuming you have it rooted
I'm aware that it's possible to modify the OS imperatively to include Nix but this is about baking Nix into the Android image declaratively.
I realize that, but given that, that script works it's proof that it's possible and it may help someone
Let's define the problem a little more:
That gives us the following picture:
/nix
is created and bind-mounted to /data/nix
, to allow the system partition to stay read-only.What does this give us?
adb shell
)..apk
files, and install them..apk
files.Open questions:
We obviously build the image with Nix and all but, after that, we "only" have a regular Android image.
Wouldn't it be cool if we could install the Nix package manager to the image? Android has a Linux kernel, filesystem and a shell which is basically all that's required to use Nix.
There are ways of using Nix on Android (nix-on-droid) but they're very limited and more "proper" solutions would require root access.
If we had
/nix/
and anix-daemon
, that'd be so useful.Not only would such an option allow you to use Nix on your phone, it'd allow Nix to become your phone, similar to NixOS. In a future where modular builds are possible, parts of the OS could be interchanged just like an updated package on NixOS. This could allow for OS upgrades with no flashing from the recovery.