From 2792bd107cf56045561cf60a12e22fcfbd38c22e Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 28 Jun 2022 03:26:08 +0200 Subject: [PATCH] stream: microvmify --- flake.nix | 2 +- hosts/containers/stream/default.nix | 47 +++++++++++++++++++++++++++-- modules/microvm.nix | 2 +- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index cd8a4415..ad75c4c1 100644 --- a/flake.nix +++ b/flake.nix @@ -544,7 +544,7 @@ stream = nixosSystem' { modules = [ - ./config/lxc-container.nix + self.nixosModules.microvm ./hosts/containers/stream ]; }; diff --git a/hosts/containers/stream/default.nix b/hosts/containers/stream/default.nix index e2f8b8cc..58218182 100644 --- a/hosts/containers/stream/default.nix +++ b/hosts/containers/stream/default.nix @@ -1,17 +1,50 @@ { zentralwerk, config, pkgs, ... }: let authFile = pkgs.writeText "htpasswd" "k-ot:sawCOTsl/fIUY"; + mac = { + pub = "DE:91:C7:51:D1:C5"; + serv = "C6:40:E0:21:9B:A4"; + }; in { networking.hostName = "stream"; c3d2.hq.statistics.enable = true; - c3d2.autoUpdate = true; + c3d2.deployment = { + server = "server9"; + autoNetSetup = false; + mounts = []; + }; + microvm.mem = 2048; + microvm.interfaces = [ { + type = "tap"; + id = "pub-stream"; + mac = mac.pub; + } { + type = "tap"; + id = "serv-stream"; + mac = mac.serv; + } ]; + microvm.shares = map (name: { + source = "/tank/storage/stream/${name}"; + mountPoint = "/${name}"; + tag = name; + proto = "virtiofs"; + socket = "${name}.socket"; + }) [ "etc" "home" "var" ]; + systemd.network = { enable = true; + links."00-serv" = { + matchConfig.MACAddress = mac.serv; + linkConfig.Name = "serv"; + }; + networks."00-serv" = { - matchConfig.MACAddress = "C6:40:E0:21:9B:A4"; + matchConfig.MACAddress = mac.serv; networkConfig.IPv6AcceptRA = false; + # try harder disabling global ipv6 + networkConfig.LinkLocalAddressing = "no"; addresses = [ { addressConfig.Address = "${config.c3d2.hosts.stream.ip4}/${toString zentralwerk.lib.config.site.net.serv.subnet4Len}"; } ]; @@ -23,9 +56,15 @@ in } ]; }; + links."00-pub" = { + matchConfig.MACAddress = mac.pub; + linkConfig.Name = "pub"; + }; + networks."01-pub" = { - matchConfig.MACAddress = "DE:91:C7:51:D1:C5"; + matchConfig.MACAddress = mac.pub; networkConfig.DHCP = "ipv4"; + networkConfig.IPv6AcceptRA = true; }; }; networking.firewall.allowedTCPPorts = [ 80 443 ]; @@ -63,4 +102,6 @@ in }; }; }; + + system.stateVersion = "22.05"; } diff --git a/modules/microvm.nix b/modules/microvm.nix index 3e5f1883..e10e76a1 100644 --- a/modules/microvm.nix +++ b/modules/microvm.nix @@ -29,7 +29,7 @@ in { options.c3d2.deployment = with lib; { server = mkOption { - type = types.enum [ "server10" ]; + type = types.enum [ "server9" "server10" ]; description = "Server that is supposed to host this MicroVM."; };