I have virtualbox enabled in the config, but it seems to be compiling it, instead of installing a binary. Why is that?
Virtualbox does not have a “redistributable” license - you either get the binaries from the official sources or you distribute the sources and have the user compile. As the official binaries don’t work on on NixOS out-of-the box, only the “compile-by-user” is the only option left.
If there is nothing specific that drives you to Virtualbox, Qemu/KVM might be a worthwhile alternative.
But it could be installed from the binary cache.
Hosting such a cache would violate their license. This is not a technical limitation, but a legal one.
I suppose you could find a way to patch up the official binaries so they work on NixOS (that’s how Brave is packaged, for instance – it downloads the official .deb and magics up the binary therein, the result is not cached but the process is very fast so it’s fine), if you are motivated enough
Some more background info:
If you have multiple machines with VirtualBox you can also set up your own binary cache or use a personal one at Cachix.