VMs with working nix tools?

Is there an an easy way to generate a VM like with build-vm (or nix-build on the appropriate expression), but get a VM that I can run tools like nixos-option and extra-container in?

Basically I want a sandbox where I can do more or less anything and test all my stuff.

In hindsight, maybe I shouldn’t expect nix to copy the currently built configuration into the VM.

What I ended up doing was conditionally setting up my NIX_PATH and creating the appropriate files, depending on whether I’m in a VM, by checking (builtins.hasAttr "cores" options.virtualisation). I would have preferred a direct check on the attribute that’s used to refer to the VM build output, but that’s closer to infiite recursion problems, hence the check if an option exists. I’m not sure if that’s the best way to do it, but it works for now.

I made a small one line patch to nixos-option to disable the read only mode for the VM.