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