From eba9d9c4cd9767628eda2ced8daca4b0015fcf5d Mon Sep 17 00:00:00 2001 From: ahuston-0 Date: Sat, 25 May 2024 16:03:38 -0400 Subject: [PATCH] idek what i did to fix this Signed-off-by: ahuston-0 --- lib/microvms.nix | 67 +++++++++++++++++++----------------- modules/opt/microvm-host.nix | 16 ++++----- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/lib/microvms.nix b/lib/microvms.nix index f95c2f4..a16f8dd 100644 --- a/lib/microvms.nix +++ b/lib/microvms.nix @@ -3,14 +3,16 @@ rec { genK3SVM = server-config: agent-config: vms: lib.mapAttrs ( - host: {ipv4,server ? false}: - genMicroVM host ipv4 "x86_64-linux" ( - if server then (import server-config) else (import agent-config) - ) + host: + { + ipv4, + server ? false, + }: + genMicroVM host ipv4 "x86_64-linux" (if server then server-config else agent-config) ) vms; genMicroVM = - hostName: ipv4: system: vm-config: + hostName: ipv4: _system: vm-config: # microvm refers to microvm.nixosModules # { @@ -20,37 +22,40 @@ rec { # ... # }: { - # The package set to use for the microvm. This also determines the microvm's architecture. - # Defaults to the host system's package set if not given. - # pkgs = import pkgs { inherit system; }; + # The package set to use for the microvm. This also determines the microvm's architecture. + # Defaults to the host system's package set if not given. + # pkgs = import pkgs { inherit system; }; - # (Optional) A set of special arguments to be passed to the MicroVM's NixOS modules. - #specialArgs = {}; + # (Optional) A set of special arguments to be passed to the MicroVM's NixOS modules. + #specialArgs = {}; - # The configuration for the MicroVM. - # Multiple definitions will be merged as expected. - config = { - # It is highly recommended to share the host's nix-store - # with the VMs to prevent building huge images. - microvm.shares = [ + # The configuration for the MicroVM. + # Multiple definitions will be merged as expected. + config = { + imports = [ vm-config ]; + # It is highly recommended to share the host's nix-store + # with the VMs to prevent building huge images. + microvm.shares = [ + { + source = "/nix/store"; + mountPoint = "/nix/.ro-store"; + tag = "ro-store"; + proto = "virtiofs"; + } + ]; + + networking = { + inherit hostName; + interfaces.ether.ipv4.addresses = [ { - source = "/nix/store"; - mountPoint = "/nix/.ro-store"; - tag = "ro-store"; - proto = "virtiofs"; - } - ]; - - networking = { - inherit hostName; - interfaces.ether.ipv4.addreses = { address = ipv4; prefixLength = 32; - }; - }; + } + ]; + }; - # Any other configuration for your MicroVM - # [...] - } // vm-config; + # Any other configuration for your MicroVM + # [...] + }; }; } diff --git a/modules/opt/microvm-host.nix b/modules/opt/microvm-host.nix index e5128c1..3673018 100644 --- a/modules/opt/microvm-host.nix +++ b/modules/opt/microvm-host.nix @@ -22,13 +22,13 @@ in microvm.vms = cfg.vms; # TODO: deprecate this once we have syslog forwarders - systemd.tmpfiles.rules = map ( - vmHost: - let - machineId = lib.addresses.machineId.${vmHost}; - in - # creates a symlink of each MicroVM's journal under the host's /var/log/journal - "L+ /var/log/journal/${machineId} - - - - /var/lib/microvms/${vmHost}/journal/${machineId}" - ) (builtins.attrNames lib.addresses.machineId); + # systemd.tmpfiles.rules = map ( + # vmHost: + # let + # machineId = lib.addresses.machineId.${vmHost}; + # in + # # creates a symlink of each MicroVM's journal under the host's /var/log/journal + # "L+ /var/log/journal/${machineId} - - - - /var/lib/microvms/${vmHost}/journal/${machineId}" + # ) (builtins.attrNames lib.addresses.machineId); }; }