From a4723c6cf2271771669ba783f0b9a0ed1bf4c22f Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 13 Jun 2022 20:00:35 +0200 Subject: [PATCH] freifunk: microvmize --- flake.nix | 1 + hosts/containers/freifunk/default.nix | 27 +++++++++++++++++++++++++-- hosts/server10/microvms.nix | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 3e01fb37..a739edd4 100644 --- a/flake.nix +++ b/flake.nix @@ -314,6 +314,7 @@ freifunk = nixosSystem' { modules = [ + microvm.nixosModules.microvm ./hosts/containers/freifunk { nixpkgs.overlays = with secrets.overlays; [ diff --git a/hosts/containers/freifunk/default.nix b/hosts/containers/freifunk/default.nix index 90586e7b..b553cdc6 100644 --- a/hosts/containers/freifunk/default.nix +++ b/hosts/containers/freifunk/default.nix @@ -24,10 +24,33 @@ let in { imports = [ "${modulesPath}/profiles/minimal.nix" - ../../../config/lxc-container.nix - ../../../config/shared.nix ]; + microvm = { + mem = 512; + hypervisor = "cloud-hypervisor"; + + shares = [ { + source = "/nix/store"; + mountPoint = "/nix/.ro-store"; + tag = "store"; + proto = "virtiofs"; + socket = "store.socket"; + } ] ++ map (dir: { + source = "/var/lib/microvms/${config.networking.hostName}/${dir}"; + mountPoint = "/${dir}"; + tag = dir; + proto = "virtiofs"; + socket = "${dir}.socket"; + }) [ "etc" "home" "var"]; + + interfaces = [ { + type = "tap"; + id = "freifunk"; + mac = "00:de:13:cb3:9a:7b"; + } ]; + }; + boot.tmpOnTmpfs = true; boot.postBootCommands = '' if [ ! -c /dev/net/tun ]; then diff --git a/hosts/server10/microvms.nix b/hosts/server10/microvms.nix index e320bca3..a3a006ff 100644 --- a/hosts/server10/microvms.nix +++ b/hosts/server10/microvms.nix @@ -2,6 +2,7 @@ microvm.autostart = [ "oparl" "leon" "nfsroot" ]; c3d2.server.bridgePorts = { serv = [ "oparl" "leon" "nfsroot" ]; + core = [ "freifunk" ]; }; nix = {