Skip to content

[ Proposal ] Nix support on Ubuntu Touch

We all know ubuntu-touch has a readonly rootfs and that this causes some limitations with apt. but as we ship a terminal people tend to try to do, well terminal stuff.

this is a proposal to make doing terminal stuff doable without requiring a readwrite rootfs. Nix is a package manager that installs package in a folder /nix/store/ folder, often called the nix store. Further more ubuntu touch has a file called /etc/system-image/writable-paths that configure a number of paths to be bind mounted into /userdata/. This makes it possible to have writable paths under /, but not neccesarily be part of the rootfs ubuntu touch ships.

afaict to support nix we only need /nix and /etc/nix to be writable where /nix is owned by the phablet user to install and configure nix on ubuntu touch

Nix works by compiling build into /nix/store and caching the resulting binaries in a "binary cache". any package in the binary cache doesn't need to compiled and can simply be downloaded.

currently nix has a limited binary cache for arm64 and even more limited binary cache for armhf, it is however possible to build packages for nix and cache them on cachix.org. all definitions to build nix packages are also on github.com/nixos/nixpkgs it is there also possible to add support for more architectures upstream to expand support.

given all that why did i file it as an issue here? Well for starters some of the features of the nix package manager may not work under the unconfined profile of the terminal app the current work around is to ssh to the device before running, so for convenience we may have to make wrapper for it. This is meant to make doing "terminal stuff" more convenient. so the terminal should handle some, if not most aspects of the configuration. We could for example see the phablet own /nix as a "home directory for the terminal". The terminal could setup and install nix for easy usage.

what did i need to do to setup nix? first of all i needed to setup /nix and /etc/nix to be writable. then i needed curl to install nix using the command bash <(curl -L https://nixos.org/nix/install) or the instruction from https://github.com/DavHau/nix-on-armv7 for my armhf device and i had to add if [ -e /home/phablet/.nix-profile/etc/profile.d/nix.sh ]; then . /home/phab let/.nix-profile/etc/profile.d/nix.sh; fi to my ~/.bashrc ......that's it. while i had to have rootfs readwrite to do it, that won't be neccesary if /nix and /etc/nix are bindmounted to be readwrite and perhaps maybe the terminal shipping curl

challenges the real challenge i have faced so far is to setup a binary cache to use with nix, as building on device is going be very cumbersome other challenges will be to integrate it, such as making the desktop file appear in the app drawer and making x apps launch properly with xmir/xwayland, this however is already done with libertine. my focus with nix is more on console apps

what i have i have managed to setup a fairly limited builder on github.com/fuseteam/thefloweringash but so far i am unable to actually fetch what i've build on that using nix. using the nix-build default.nix --argstr target armv7l-hf-multiplatform --argstr package vim --show-trace --keep-going command it should be possible to cross-build the package using the default.nix on that repo

so in the end what will nix bring to the table for the terminal? Nix will enable installation of command line tools via the terminal. utilities installed with nix are sandboxed from the system (not sure how that works atm) packages installed by nix are self contained packages installed by nix don't make changes to the rootfs

i will keep this issue up to date with my findings and will continue to hammer it untill i figure out what i need for a working binary cache

Edited by Rahammetoela Toekiman