From 44dbc61ce7274759fe800deeb6d462f7ed3b86f2 Mon Sep 17 00:00:00 2001
From: Benoit Donneaux <benoit@leastauthority.com>
Date: Tue, 6 Jun 2023 10:42:06 +0000
Subject: [PATCH] Enable serial and use var. for pool

Signed-off-by: Benoit Donneaux <benoit@leastauthority.com>
---
 morph/grid/local/Vagrantfile | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/morph/grid/local/Vagrantfile b/morph/grid/local/Vagrantfile
index 40ec9b2f..30060cf9 100644
--- a/morph/grid/local/Vagrantfile
+++ b/morph/grid/local/Vagrantfile
@@ -4,6 +4,9 @@
 # This Vagrantfile worked for Florian Sesser using Vagrant 2.2.16dev and
 # the VirtualBox Hypervisor. Earlier Vagrant and LibVirt did not work.
 
+# Get the LibVirt pool name or use default
+pool_name = ENV.has_key?('POOL_NAME') ? ENV['POOL_NAME'] : 'default'
+
 Vagrant.configure("2") do |config|
   # For a complete reference, please see the online documentation at
   # https://docs.vagrantup.com.
@@ -14,9 +17,9 @@ Vagrant.configure("2") do |config|
   # 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.storage_pool_name = pool_name
+    libvirt.snapshot_pool_name = pool_name
+    # No need of graphics - better use serial
     libvirt.graphics_type = "none"
     libvirt.video_type = "none"
   end
@@ -89,9 +92,11 @@ Vagrant.configure("2") do |config|
   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: "echo '{ nix.trustedUsers = [ \"@wheel\" \"root\" \"vagrant\" ]; boot.kernelParams = [ \"console=tty0\" \"console=ttyS0,115200\" ]; }' > /etc/nixos/custom-configuration.nix"
   config.vm.provision "shell", inline: "nixos-rebuild switch"
   config.vm.provision "shell", inline: "systemctl stop firewall.service"
+  config.vm.provision "shell", inline: "systemctl start serial-getty@ttyS0.service"
 
   config.trigger.after :up do |trigger|
     trigger.info = "Hostname and IP address this host actually uses:"
-- 
GitLab