I’d like to play with Nix on my Raspberry Pi, but have already installed and set up Raspbian. Because of this I would like to just install the the package manager.
If I remember correctly, for armv7l the only way to get Nix would be to compile it from the source, and compiling from source requires a patch for armv7l.
There’s been some very recent work on getting cross-compilation working well for NixOS. I was able to use this configuration to cross-compile to a Raspberry Pi Zero W:
But it hasn’t been reviewed, and I’m a little bit hesitant to merge it as is. If anyone can review that, it would make this process much easier! We could add it as a job for cross-trunk, and you would just download it from:
It seems that adding libatomic_ops as a dependency was all that was needed to cross-compile Nix (or at least finish the build)? Though I’m not sure how the conditional would look like since it seems native compilation works fine without it.
After a weekend deep dive into the Nix arm world I finally managed to build a release tarball of nix which can be installed on Raspberry Pi OS / Raspbian or any other armv7l based linux.
The build was done on a raspberry with Raspberry Pi OS running a docker container of debian testing.
→ see Dockerfile in the repo
This is only possible because there is now a nix package available in the debian-testing repo. This nix version is used inside docker to compile a proper nix binary tarball for armv7l.
It really was a long way to figuring that out. It would be much simpler if either an official armv7l release of nix or a working cross build recipe would exist. Both is not the case. But there are open PRs like for example this one.
If someone could push this forward it would be amazing.
Afterwards just use the official aarch64 version of nix. If nix doesn’t detect the platform correctly. add a system = aarch64-linux to /etc/nix/nix.conf.
Aarch64 is officially supported by nix and has full availability via official binary cache. Therefore this is definitely the better option compared to messing around with armv7l.
@DavHau Thank you so much for posting this! Building Nix myself seemed like too much effort for too little reward, but now that I’ve switched to AArch64, I don’t have to