2024-05-25 15:19:01 -04:00
|
|
|
{ lib, ... }:
|
|
|
|
rec {
|
2024-05-25 15:56:49 -04:00
|
|
|
genK3SVM =
|
|
|
|
server-config: agent-config: vms:
|
2024-05-25 15:19:01 -04:00
|
|
|
lib.mapAttrs (
|
2024-05-25 15:56:49 -04:00
|
|
|
host: {ipv4,server ? false}:
|
|
|
|
genMicroVM host ipv4 "x86_64-linux" (
|
|
|
|
if server then (import server-config) else (import agent-config)
|
2024-05-25 15:19:01 -04:00
|
|
|
)
|
2024-05-25 15:56:49 -04:00
|
|
|
) vms;
|
2024-05-25 15:19:01 -04:00
|
|
|
|
|
|
|
genMicroVM =
|
|
|
|
hostName: ipv4: system: vm-config:
|
|
|
|
# microvm refers to microvm.nixosModules
|
|
|
|
|
2024-05-25 15:56:49 -04:00
|
|
|
# {
|
|
|
|
# config,
|
|
|
|
# pkgs,
|
|
|
|
# lib,
|
|
|
|
# ...
|
|
|
|
# }:
|
2024-05-25 15:19:01 -04:00
|
|
|
{
|
|
|
|
# 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.
|
2024-05-25 15:56:49 -04:00
|
|
|
# pkgs = import pkgs { inherit system; };
|
2024-05-25 15:19:01 -04:00
|
|
|
|
|
|
|
# (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 = [
|
|
|
|
{
|
|
|
|
source = "/nix/store";
|
|
|
|
mountPoint = "/nix/.ro-store";
|
|
|
|
tag = "ro-store";
|
|
|
|
proto = "virtiofs";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
inherit hostName;
|
|
|
|
interfaces.ether.ipv4.addreses = {
|
|
|
|
address = ipv4;
|
2024-05-25 15:56:49 -04:00
|
|
|
prefixLength = 32;
|
2024-05-25 15:19:01 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Any other configuration for your MicroVM
|
|
|
|
# [...]
|
|
|
|
} // vm-config;
|
|
|
|
};
|
|
|
|
}
|