feat: allow multiple interfaces in guests

This commit is contained in:
Patrick 2024-12-19 21:46:11 +01:00
parent da6945497b
commit 6a4736e077
No known key found for this signature in database
GPG key ID: 451F95EFB8BECD0F
4 changed files with 330 additions and 245 deletions

View file

@ -12,10 +12,10 @@ guestName: guestCfg: {
nameValuePair
;
in {
inherit (guestCfg.container) macvlans;
ephemeral = true;
privateNetwork = true;
autoStart = guestCfg.autostart;
macvlans = ["${guestCfg.container.macvlan}:${guestCfg.networking.mainLinkName}"];
extraFlags = [
"--uuid=${builtins.substring 0 32 (builtins.hashString "sha256" guestName)}"
];
@ -28,7 +28,11 @@ in {
);
nixosConfiguration = (import "${inputs.nixpkgs}/nixos/lib/eval-config.nix") {
specialArgs = guestCfg.extraSpecialArgs;
prefix = ["nodes" "${config.node.name}-${guestName}" "config"];
prefix = [
"nodes"
"${config.node.name}-${guestName}"
"config"
];
system = null;
modules =
[
@ -49,13 +53,15 @@ in {
# and not recursive. This allows us to have a fileSystems entry for each
# bindMount which other stuff can depend upon (impermanence adds dependencies
# to the state fs).
fileSystems = flip mapAttrs' guestCfg.zfs (_: zfsCfg:
nameValuePair zfsCfg.guestMountpoint {
neededForBoot = true;
fsType = "none";
device = zfsCfg.guestMountpoint;
options = ["bind"];
});
fileSystems = flip mapAttrs' guestCfg.zfs (
_: zfsCfg:
nameValuePair zfsCfg.guestMountpoint {
neededForBoot = true;
fsType = "none";
device = zfsCfg.guestMountpoint;
options = ["bind"];
}
);
}
(import ./common-guest-config.nix guestName guestCfg)
]