try to fix attrset generation

Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
ahuston-0 2024-05-25 15:56:49 -04:00
parent 9985fc8778
commit 1c596593ca
No known key found for this signature in database
GPG Key ID: 1FACF4075E3212F7
2 changed files with 23 additions and 32 deletions

View File

@ -1,34 +1,28 @@
{ lib, ... }:
rec {
genK3SFromList =
server-config: agent-config:
{
host,
ipv4,
server ? false,
}@args:
genK3SVM =
server-config: agent-config: vms:
lib.mapAttrs (
args:
lib.rad-dev.microvms.genMicroVM args.host args.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 (import server-config) else (import agent-config)
)
) args;
) vms;
genMicroVM =
hostName: ipv4: system: vm-config:
# microvm refers to microvm.nixosModules
# {
# config,
# pkgs,
# lib,
# ...
# }:
{
config,
pkgs,
lib,
...
}:
{
${hostName} = {
# 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; };
# pkgs = import pkgs { inherit system; };
# (Optional) A set of special arguments to be passed to the MicroVM's NixOS modules.
#specialArgs = {};
@ -51,7 +45,7 @@ rec {
inherit hostName;
interfaces.ether.ipv4.addreses = {
address = ipv4;
prefixLength = 24;
prefixLength = 32;
};
};
@ -59,5 +53,4 @@ rec {
# [...]
} // vm-config;
};
};
}

View File

@ -6,22 +6,20 @@
...
}:
let
inherit (lib.rad-dev.microvm) genK3SFromList;
inherit (lib.rad-dev.microvm) genK3SVM;
in
{
# rad-dev.microvm-host.enable = true;
rad-dev.microvm-host.vms =
genK3SFromList (src + "/modules/opt/k3s-server.nix") (src + "/modules/opt/k3s-agent.nix")
[
genK3SVM (src + "/modules/opt/k3s-server.nix") (src + "/modules/opt/k3s-agent.nix")
{
host = "ph-server-1";
"ph-server-1" = {
ipv4 = "192.168.69.10";
server = true;
}
{
host = "ph-agent-1";
ipv4 = "192.168.69.30";
}
];
};
# "ph-agent-1" = {
# ipv4 = "192.168.69.30";
# };
};
}