kimb.dev

Kicking the tires on Nix-Portable

I love nix. I’m at Nix Camp this week, and I’m having a blast.

But nix isn’t the friendliest thing to install. That’s part of why I prefer NixOS over using Nix as a package manager or worse, running it on MacOS. It badly wants to create a store at /nix, and many devices don’t want you touching that, even as root. And what if they do let you install nix, but the quriky gizmo won’t function with it?

The RG35XXSP

Before this trip, I treated myself to a neat Chinese emulator handheld, the Anbernic RG35XXSP. For ~$50, you get a clamshell SBC Linux machine with a quad-core ARM processor. The community consensus is that the machine can emulate anything up to most of the 32 bit era.

Being a millenial, I couldn’t resist a new GameBoy Advance SP. It’s a very Proustian rectangle. I wiped the stock os for a distro called MuOS because reddit said it was good for people who know how to flash an sd card. I mostly played some GBA games I never tried like MegaMan Battle Network, then chucked it in my bag because it’s smaller than my Steam Deck, and flew off to Nix Camp.

Last night, after some fun exploring Liverpool with my campmates and drinking a bit more than I normally do, I sat down to play some Chrono Trigger. The other folks started hacking away on their laptops, and I felt self conscious for not nixxing. So I checked out what exactly I installed on my itty bitty gaming machine.

It turns out it will run aarch64 binaries, meaning Nixpkgs can give it binaries. Unfortunately, the determinate nix installer NOPED out. I don’t blame her. No systemd, not much ram, a funky embedded linux for a device not in the mainline…

Another Way

But what if I didn’t need to install nix? After all, I run programs all the time in nix without “installing” them like nix run nixpkgs#bottom.

Enter nix-portable, an encapsulation of nix in a static binary. On most x86-64/aarch64 linux machines, you can just run

curl -L https://github.com/DavHau/nix-portable/releases/latest/download/nix-portable-$(uname -m) > ./nix-portable

chmod +x ./nix-portable

To my delight, this worked great on the RG35XXSP. It hung for probably a good minute or two at first, but give the poor GameBoy drag king a break. Eventually, it started ingesting a variety of dependencies, and I was met with a jovial cowsay. I’ll embed images when I’m less of a hugo baby and am not fretting about how to minimax image compression.

The sucky part

Drunk on this minor victory, I then tried running it on my vacuum cleaner. My vacuum cleaner is a Dreame L10S robot vacuum, which I rooted and installed with Valetudo. Valetudo is a wonderful project, and thanks to Tailscale, it’s easy to talk to it from across the pond. This is life in 2024.

These vacuums are fun devices for nerds, because not only do they clean for you, they also are rolling Linux machines. The Valetudo team are quite opinionated and want your rolling server with cameras to not be insecure, and badly don’t want the scandal of hackers turning your vacuum into a surveillance machine. This is fair, and honestly, you write such a good application, you are welcome to set boundaries :)

But it has no kind of package management as far as I can tell, so running nix would have been awesome. Unfortunately, the vacuum runs busybox instead of bash, and gives the error env: can't execute 'bash': No such file or directory.

I fixed that by copying over this static build of bash, but then I ran into Fatal error: nix is unable to build packages when I tried to run any nix command. And I got the same message from remote builders.

I get the feeling I can get nix running, and maybe I just need to copy over gcc or whatever, but the poor little machine ran out of space when I tried to get a copy of gcc on it. I’m going to focus on contributing to nixpkgs instead. But I will probably pull at this thread again.

Reply to this post by email ↪