A Couple Small Nix Tips

submited by
Style Pass
2023-01-25 10:00:08

Here’s a bunch of small nix tips, for my own future reference. Everything assumes you’ve enabled nix-command and flakes experimental features.

Nix has a neat feature where you can add ‘remote builders’ which it can send build tasks to during the build process. This is especially useful if you’re e.g. building a Linux package from macOS. There’s two ways to do this:

nixbuild is a service that providers remote Linux builders as a service—you even get a quite generous 25 CPU hours per month. Setup is not too complicated.

You can run a ‘remote’ builder VM on your computer that runs Linux. The coolest implementation I’ve seen of this is using Rosetta 2 to execute x86_64 binaries in the VM so you get two architectures (aarch64 and x86_64) for the price of one.

A way of running a Linux VM through QEMU as a builder was recently merged into Nixpkgs, this doesn’t provide the Rosetta 2 thing though because QEMU doesn’t support that.

Leave a Comment