NixOps VDIs have the same UUIDs
When working with two different deployments that use different versions of nixpkgs, vboxmanage will complain that it cannot clone a hard disk out of the nix store because the UUID already exists.
Lets say I'm deploying webserver on 19.03 when I have previously deployed something on 19.09. NixOps will call vboxmanage clonehd which gives the following error (it complains about the two VDIs having the same UUID).
$ VBoxManage clonehd '/nix/store/03fha2syjqijs88pifmfgabix8lpdg6j-virtualbox-nixops-19.09.vmdk' '/Users/lev/VirtualBox VMs/nixops-7e888075-9a9a-11e9-a5f2-d0817ad44941-webserver/disk1.vdi' --format VDI
VBoxManage: error: Cannot register the hard disk '/nix/store/03fha2syjqijs88pifmfgabix8lpdg6j-virtualbox-nixops-19.09.vmdk' {d50d2572-7082-4601-9e70-24b663fc32bb} because a hard disk '/nix/store/j3y7f953brdgxrmclnicg65vfvnnhnbn-virtualbox-nixops-19.03.vmdk' with UUID {d50d2572-7082-4601-9e70-24b663fc32bb} already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 191 of file VBoxManageDisk.cpp
I tried running sudo VBoxManage internalcommands sethduuid /nix/store/j3y7f953brdgxrmclnicg65vfvnnhnbn-virtualbox-nixops-19.03.vmdk to change the uuid but it doesn't seem to work.
In order to switch between disks you must delete nixops deployments and vbox mediums:
$ nixops destroy --all
$ nixops delete --all
$ sudo vboxmanage closemedium d50d2572-7082-4601-9e70-24b663fc32bb --delete
$ nix-store --delete /nix/store/j3y7f953brdgxrmclnicg65vfvnnhnbn-virtualbox-nixops-19.03.vmdk
To further the comment above, it seems that in later versions of VirtualBox the command to delete the hdd is now:
$ VBoxManage closemedium disk d50d2572-7082-4601-9e70-24b663fc32bb --delete