modules/cluster/deployment: let microvms specify their nets by providing just a default

This commit is contained in:
Astro 2022-11-26 01:41:28 +01:00
parent 65a91dc324
commit 7bc3b49cc3
2 changed files with 12 additions and 15 deletions

View File

@ -1,4 +1,4 @@
{ lib, ... }: { zentralwerk, lib, ... }:
# our custom options # our custom options
{ {
options.deployment = with lib; { options.deployment = with lib; {
@ -12,7 +12,14 @@
}; };
networks = mkOption { networks = mkOption {
type = with types; listOf str; type = with types; listOf str;
default = [ "serv" ]; default = builtins.attrNames (
lib.filterAttrs (net: { hosts4, hosts6, ... }:
hosts4 ? ${hostName} ||
lib.filterAttrs (ctx: hosts6:
hosts6 ? ${hostName}
) hosts6 != {}
) zentralwerk.lib.config.site.net
);
}; };
persistedShares = mkOption { persistedShares = mkOption {
type = with types; listOf str; type = with types; listOf str;

View File

@ -8,17 +8,9 @@ let
flpk = "flpk-gw"; flpk = "flpk-gw";
}; };
nets = builtins.attrNames (
lib.filterAttrs (net: { hosts4, hosts6, ... }:
hosts4 ? ${hostName} ||
lib.filterAttrs (ctx: hosts6:
hosts6 ? ${hostName}
) hosts6 != {}
) zentralwerk.lib.config.site.net
);
inherit (config.networking) hostName; inherit (config.networking) hostName;
inherit (config.system.build.skyflake-deployment) user repo vmName; inherit (config.system.build.skyflake-deployment) user repo vmName;
inherit (config.deployment) networks;
generateMacAddress = net: generateMacAddress = net:
let let
@ -37,8 +29,6 @@ let
in in
{ {
deployment.networks = nets;
microvm = { microvm = {
hypervisor = "cloud-hypervisor"; hypervisor = "cloud-hypervisor";
vcpu = config.deployment.vcpu; vcpu = config.deployment.vcpu;
@ -104,7 +94,7 @@ in
# rename interface to net name # rename interface to net name
linkConfig.Name = net; linkConfig.Name = net;
}; };
}) {} nets; }) {} networks;
networks = builtins.foldl' (networks: net: networks // { networks = builtins.foldl' (networks: net: networks // {
"30-${net}" = "30-${net}" =
@ -135,6 +125,6 @@ builtins.filter (hosts6: hosts6 ? ${hostName}) (
) )
); );
}; };
}) {} nets; }) {} networks;
}; };
} }