### Declaring a MicroVM The hosts nixosSystems modules should be declared using the ```makeMicroVM``` helper function. Use durruti as orientation: ``` nix modules = makeMicroVM "durruti" "10.0.0.5" [ ./durruti/configuration.nix ]; ``` "durruti" is the hostname. "10.0.0.5" is the IP assigned to its tap interface. ### Testing MicroVMs locally MicroVMs can be built and run easily on your local host. For durruti this is done by: ``` bash sudo nix run .\#nixosConfigurations.durruti.config.microvm.declaredRunner ``` It seems to be necessary to run this as root so that the according tap interface can be created. To be able to ping the VM or give Internet Access to the VM your host needs to be setup as described below. ### Host Setup #### Network Bridge To provide network access to the VMs a bridge interface needs to be created on your host. For that: - Add the infrastructure flake as input to your hosts flake - Add ```inputs.malobeo.nixosModules.malobeo``` to your hosts imports - enable the host bridge: ```services.malobeo.microvm.enableHostBridge = true;``` If you want to provide Internet access to the VM it is necessary to create a nat. This could be done like this: ``` nix networking.nat = { enable = true; internalInterfaces = [ "microvm" ]; externalInterface = "eth0"; #change to your interface name }; ``` #### Auto Deploy VMs By default no MicroVMs will be initialized on the host - this should be done using the microvm commandline tool. But since we want to always deploy certain VMs it can be configured using the ```malobeo.microvm.deployHosts``` option. VMs configured using this option will be initialized and autostarted at boot. Updating still needs to be done imperative, or by enabling autoupdates.nix The following example would init and autostart durruti and gitea: ``` nix malobeo.microvm.deployHosts = [ "durruti" "gitea" ]; ```