You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.0 KiB

2 years ago
  1. # Test nix-shell in vagrant VMs
  2. Set up a vagrant guest VM, and test the dev environment inside the guest.
  3. - Only tested on nixos host with _libvirt_ virtualization provider.
  4. - Assumes that the host has an SSH agent. The agent is used for SSH auth inside
  5. the guest.
  6. - Upon creation (`vagrant up`) a copy of this local repo is rsynced to the
  7. `/hyperplonk` directory in the guest. The tests are run against these files. To
  8. see changes made to the code on the host run `vagrant reload` to re-sync the
  9. source code from host to guest.
  10. ## Available vagrant boxes
  11. The following boxes are available:
  12. - `ubuntu`: `ubuntu20.04` + `nix`
  13. - `ubuntu_rustup`: `ubuntu20.04` + `nix` + `rustup`
  14. More OSes/VMs can be added in the `Vagrantfile`.
  15. Append name of box after vagrant command to apply to a single box only
  16. vagrant up ubuntu_rustup
  17. vagrant ssh ubuntu_rustup
  18. ## Usage
  19. Enable `libvrtd` on your host:
  20. [ubuntu](https://ubuntu.com/server/docs/virtualization-libvirt),
  21. [nixos](https://nixos.wiki/wiki/Libvirt).
  22. Make sure we are in the `libvirtd` group.
  23. Install `libvirt` vagrant plugin (not needed on nixos):
  24. vagrant plugin install vagrant-libvirt
  25. Activate nix-shell in this directory (or ensure vagrant is installed):
  26. nix-shell
  27. Start vm:
  28. vagrant up ubuntu
  29. There is a password prompt to add the insecure vagrant key to the agent. One can
  30. supply an empty password once or cancel the prompt each time one runs `vagrant
  31. ssh`.
  32. Run formatter, linter, tests inside a nix-shell environment inside the `ubuntu`
  33. guest:
  34. vagrant ssh ubuntu -- -t /vagrant/test-nix-shell-guest
  35. This runs the `test-nix-shell-guest` script in this directory inside the vagrant
  36. guest.
  37. Clean up with
  38. vagrant destroy ubuntu
  39. ## Notes
  40. - After editing the Vagrantfile, `vagrant reload` will apply the changes.
  41. - When making substantial changes or changing names of vagrant boxes I usually
  42. have more luck with running `vagrant destroy` with the previous `Vagrantfile`
  43. and then `vagrant up` again with the new `Vagrantfile`.