.. [#] The author of this documentation wasted a lot of time trying to get Vagrant to work with KVM/libvirt. Issues with networking that looked like guest misconfigurations vanished after changing to the better-tested combination of Vagrant and VirtualBox.
Pre-Vagrant 2.2.16: Get Vagrant with the required fixes for NixOS guests
The Vagrant nixos-guest template `received a critical update on 2021-03-08 <https://github.com/hashicorp/vagrant/commit/990d94ed9d0b3092e855bc1bb9deeeb7aa7792cf>`_ which came out with Vagrant version 2.2.16.
If you run an older Nixpkgs, retrieve and use the latest Vagrant development version like so::
3. Edit the output: Add the IPs from ``grid.nix`` to the ``vagrant-ssh-config`` **Host match blocks** so the config reads like::
4. Edit the generated configuration: Add the ``publicIP`` addresses from ``grid.nix`` to sshconfig **Host** match blocks (**not** HostName) so the ``Host`` lines all read like::
Host payments1 192.168.67.21
HostName 192.168.67.21
HostName 127.0.0.1
User vagrant
Port 22
[...]
4. Then, make morph use this ssh config either - with newer morph [#]_ - by pointing it to it::
export SSH_CONFIG_FILE=./vagrant-ssh-config
From version 1.5.0 Morph honors the ``SSH_CONFIG_FILE`` environment variable `since 3f90aa88 (March 2020, v 1.5.0) <https://github.com/DBCDK/morph/commit/3f90aa885fac1c29fce9242452fa7c0c505744ef#diff-d155ad793bd62e6ea4c44ba985049ecb13a4f4f32f799791b2bce695a16c0101>`_, so in the future this will get a bit more convenient.
Or, with older morph, adding the config to your user's ``~/.ssh/config`` file.
5. Add your SSH key to users.nix so you'll be able to log in after deploying the new configuration::
.. [#] Morph honors the ``SSH_CONFIG_FILE`` environment variable `since 3f90aa88 (March 2020, v 1.5.0) <https://github.com/DBCDK/morph/commit/3f90aa885fac1c29fce9242452fa7c0c505744ef#diff-d155ad793bd62e6ea4c44ba985049ecb13a4f4f32f799791b2bce695a16c0101>`_.
$EDITOR secrets/users.nix
5. Then, build and deploy our software to the Vagrant VMs::
morph build grid.nix
morph push grid.nix
morph deploy grid.nix boot
vagrant halt
vagrant up
morph upload-secrets grid.nix
morph deploy grid.nix switch
You will now be able to log in with the users and keys you set in your ``localdev-users.nix`` file.
You should now be able to log in with the users and keys you set in your ``users.nix`` file.