Custom "remote" builder command. (Build via container.)

I have nix installed on an Apple Silicon Mac, and I am trying to use it to build a Linux container image via pkgs.dockerTools.buildImage. The trouble is that one of the packages I want to include isn’t available in the build cache and needs to be built from source. I discovered nix’s remote builder functionality, but all of the examples of it that I’ve seen involve setting up credentials to connect to a persistent remote machine via ssh.

What I’d like to do instead is leverage Apple Container to spin up a temporary aarch64 or (via Rosetta 2) x86_64 Linux container locally to do the build when needed, without needing a persistent builder with SSH access. Are there any customization points in the remote builder functionality (or otherwise) that would allow me to achieve this?

DS added an external-builders feature to their fork exactly for this is case

I don’t think it made it into upstream nix yet though

Thanks! It looks like external-builders is actually in the latest Nix release as an experimental feature, so I’ll see if I can figure out how to make it do its thing.