diff --git a/morph/grid/local/README.rst b/morph/grid/local/README.rst index 48f395cb82fc272481a61f0d1ab425ffbd20cd02..2246d40b79816f4f652557f2a3bb09bf02275058 100644 --- a/morph/grid/local/README.rst +++ b/morph/grid/local/README.rst @@ -17,6 +17,12 @@ Use the local development environment # Save bytes and build time, optional but recommended: virtualisation.virtualbox.host.headless = true; + # Create a local pool for libvirt + mkdir -p ~/.libvirt/images + sudo virsh pool-define-as morph_local --type dir --target ${HOME}/.libvirt/images + virsh pool-autostart morph_local + virsh pool-start morph_local + 1. Enter the morph local grid directory:: cd morph/grid/local @@ -27,7 +33,8 @@ Use the local development environment 3. Build and start the VMs:: - VAGRANT_DEFAULT_PROVIDER=virtualbox vagrant up + export VAGRANT_DEFAULT_PROVIDER=virtualbox # Use `libvirt` for QEmu + vagrant up # Add `--no-parallel` on low resources 4. Then, add the Vagrant SSH configuration to your user's ``~/.ssh/config`` file:: @@ -45,7 +52,7 @@ Use the local development environment morph push grid.nix morph deploy grid.nix boot vagrant halt - vagrant up + vagrant up --no-destroy-on-error # Add `--no-parallel` on low resources morph upload-secrets grid.nix You should now be able to log in with the users and keys you set in your ``users.nix`` file. diff --git a/morph/grid/local/Vagrantfile b/morph/grid/local/Vagrantfile index 64d4aec5aadc67e48c91cb0b8154b1107c23f1bb..40ec9b2fbe4a49b5cc04b1b271605be5bd27636c 100644 --- a/morph/grid/local/Vagrantfile +++ b/morph/grid/local/Vagrantfile @@ -8,11 +8,28 @@ Vagrant.configure("2") do |config| # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. + # We do not need to sync the working dir. with our guests + config.vm.synced_folder ".", "/vagrant", disabled: true + + # Tune QEmu guests + config.vm.provider :libvirt do |libvirt| + # Using a specific pool may help to manage the disk space + libvirt.storage_pool_name = "morph_local" + libvirt.snapshot_pool_name = "morph_local" + # No need of graphics + libvirt.graphics_type = "none" + libvirt.video_type = "none" + end + config.vm.define "payments.localdev" do |config| config.vm.hostname = "payments" config.vm.box = "esselius/nixos" config.vm.box_version = "20.09" config.vm.box_check_update = false + config.vm.provider :libvirt do |domain| + domain.cpus = 2 + domain.memory = 1024 + end # To use the self-updating deployment system you need more memory. Giving # all of the VMs enough memory for this is rather taxing, though, and the @@ -40,6 +57,10 @@ Vagrant.configure("2") do |config| config.vm.box = "esselius/nixos" config.vm.box_version = "20.09" config.vm.box_check_update = false + config.vm.provider :libvirt do |domain| + domain.cpus = 2 + domain.memory = 1024 + end config.vm.network "private_network", ip: "192.168.56.22" end @@ -48,6 +69,10 @@ Vagrant.configure("2") do |config| config.vm.box = "esselius/nixos" config.vm.box_version = "20.09" config.vm.box_check_update = false + config.vm.provider :libvirt do |domain| + domain.cpus = 2 + domain.memory = 1024 + end config.vm.network "private_network", ip: "192.168.56.23" end @@ -56,12 +81,17 @@ Vagrant.configure("2") do |config| config.vm.box = "esselius/nixos" config.vm.box_version = "20.09" config.vm.box_check_update = false + config.vm.provider :libvirt do |domain| + domain.cpus = 2 + domain.memory = 1024 + end config.vm.network "private_network", ip: "192.168.56.24" end # To make the VMs assign the static IPs to the network interfaces we need a rebuild: config.vm.provision "shell", inline: "echo '{nix.trustedUsers = [ \"@wheel\" \"root\" \"vagrant\" ];}' > /etc/nixos/custom-configuration.nix" config.vm.provision "shell", inline: "nixos-rebuild switch" + config.vm.provision "shell", inline: "systemctl stop firewall.service" config.trigger.after :up do |trigger| trigger.info = "Hostname and IP address this host actually uses:" diff --git a/morph/lib/hardware-vagrant.nix b/morph/lib/hardware-vagrant.nix index 6c41af4923861e89d144303d129d7babde494363..f52d12126f7ca2d9abf55e22f9dc8a8586cb5c41 100644 --- a/morph/lib/hardware-vagrant.nix +++ b/morph/lib/hardware-vagrant.nix @@ -17,7 +17,7 @@ config = { virtualisation.virtualbox.guest.enable = true; - boot.loader.grub.device = "/dev/sda"; + boot.loader.grub.device = "/dev/vda"; boot.initrd.availableKernelModules = [ "ata_piix" "sd_mod" "sr_mod" ]; boot.kernel.sysctl = { "vm.swappiness" = 0; }; @@ -47,7 +47,7 @@ fileSystems."/storage" = { fsType = "tmpfs"; }; fileSystems."/" = - { device = "/dev/sda1"; + { device = "/dev/vda1"; fsType = "ext4"; };