feat: upstream node generation
This commit is contained in:
parent
f1a3f0303b
commit
93b08971cf
9 changed files with 268 additions and 48 deletions
|
@ -1,12 +1,14 @@
|
|||
_guestName: guestCfg: {lib, ...}: let
|
||||
inherit
|
||||
(lib)
|
||||
_guestName: guestCfg:
|
||||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkForce
|
||||
nameValuePair
|
||||
listToAttrs
|
||||
flip
|
||||
;
|
||||
in {
|
||||
in
|
||||
{
|
||||
node.name = guestCfg.nodeName;
|
||||
node.type = guestCfg.backend;
|
||||
|
||||
|
@ -20,20 +22,20 @@ in {
|
|||
systemd.network.networks = listToAttrs (
|
||||
flip map guestCfg.networking.links (
|
||||
name:
|
||||
nameValuePair "10-${name}" {
|
||||
matchConfig.Name = name;
|
||||
DHCP = "yes";
|
||||
# XXX: Do we really want this?
|
||||
dhcpV4Config.UseDNS = false;
|
||||
dhcpV6Config.UseDNS = false;
|
||||
ipv6AcceptRAConfig.UseDNS = false;
|
||||
networkConfig = {
|
||||
IPv6PrivacyExtensions = "yes";
|
||||
MulticastDNS = true;
|
||||
IPv6AcceptRA = true;
|
||||
};
|
||||
linkConfig.RequiredForOnline = "routable";
|
||||
}
|
||||
nameValuePair "10-${name}" {
|
||||
matchConfig.Name = name;
|
||||
DHCP = "yes";
|
||||
# XXX: Do we really want this?
|
||||
dhcpV4Config.UseDNS = false;
|
||||
dhcpV6Config.UseDNS = false;
|
||||
ipv6AcceptRAConfig.UseDNS = false;
|
||||
networkConfig = {
|
||||
IPv6PrivacyExtensions = "yes";
|
||||
MulticastDNS = true;
|
||||
IPv6AcceptRA = true;
|
||||
};
|
||||
linkConfig.RequiredForOnline = "routable";
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
guestName: guestCfg: {
|
||||
guestName: guestCfg:
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
extraModules,
|
||||
...
|
||||
}: let
|
||||
inherit
|
||||
(lib)
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
flip
|
||||
mapAttrs'
|
||||
nameValuePair
|
||||
;
|
||||
in {
|
||||
in
|
||||
{
|
||||
inherit (guestCfg.container) macvlans;
|
||||
ephemeral = true;
|
||||
privateNetwork = true;
|
||||
|
@ -21,10 +24,10 @@ in {
|
|||
];
|
||||
bindMounts = flip mapAttrs' guestCfg.zfs (
|
||||
_: zfsCfg:
|
||||
nameValuePair zfsCfg.guestMountpoint {
|
||||
hostPath = zfsCfg.hostMountpoint;
|
||||
isReadOnly = false;
|
||||
}
|
||||
nameValuePair zfsCfg.guestMountpoint {
|
||||
hostPath = zfsCfg.hostMountpoint;
|
||||
isReadOnly = false;
|
||||
}
|
||||
);
|
||||
nixosConfiguration = (import "${inputs.nixpkgs}/nixos/lib/eval-config.nix") {
|
||||
specialArgs = guestCfg.extraSpecialArgs;
|
||||
|
@ -55,16 +58,17 @@ in {
|
|||
# to the state fs).
|
||||
fileSystems = flip mapAttrs' guestCfg.zfs (
|
||||
_: zfsCfg:
|
||||
nameValuePair zfsCfg.guestMountpoint {
|
||||
neededForBoot = true;
|
||||
fsType = "none";
|
||||
device = zfsCfg.guestMountpoint;
|
||||
options = ["bind"];
|
||||
}
|
||||
nameValuePair zfsCfg.guestMountpoint {
|
||||
neededForBoot = true;
|
||||
fsType = "none";
|
||||
device = zfsCfg.guestMountpoint;
|
||||
options = [ "bind" ];
|
||||
}
|
||||
);
|
||||
}
|
||||
(import ./common-guest-config.nix guestName guestCfg)
|
||||
]
|
||||
++ guestCfg.modules;
|
||||
++ guestCfg.modules
|
||||
++ extraModules;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
guestName: guestCfg: {
|
||||
guestName: guestCfg:
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
extraModules,
|
||||
...
|
||||
}: let
|
||||
inherit
|
||||
(lib)
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
concatMapAttrs
|
||||
flip
|
||||
mapAttrs
|
||||
|
@ -13,19 +15,22 @@ guestName: guestCfg: {
|
|||
mkForce
|
||||
replaceStrings
|
||||
;
|
||||
in {
|
||||
in
|
||||
{
|
||||
specialArgs = guestCfg.extraSpecialArgs;
|
||||
pkgs = inputs.self.pkgs.${guestCfg.microvm.system};
|
||||
inherit (guestCfg) autostart;
|
||||
config = {
|
||||
imports =
|
||||
guestCfg.modules
|
||||
extraModules
|
||||
++ guestCfg.modules
|
||||
++ [
|
||||
(import ./common-guest-config.nix guestName guestCfg)
|
||||
(
|
||||
{config, ...}: {
|
||||
{ config, ... }:
|
||||
{
|
||||
# Set early hostname too, so we can associate those logs to this host and don't get "localhost" entries in loki
|
||||
boot.kernelParams = ["systemd.hostname=${config.networking.hostName}"];
|
||||
boot.kernelParams = [ "systemd.hostname=${config.networking.hostName}" ];
|
||||
}
|
||||
)
|
||||
];
|
||||
|
@ -47,13 +52,15 @@ in {
|
|||
|
||||
# MACVTAP bridge to the host's network
|
||||
interfaces = flip mapAttrsToList guestCfg.microvm.interfaces (
|
||||
_: {
|
||||
_:
|
||||
{
|
||||
mac,
|
||||
hostLink,
|
||||
...
|
||||
}: {
|
||||
}:
|
||||
{
|
||||
type = "macvtap";
|
||||
id = "vm-${replaceStrings [":"] [""] mac}";
|
||||
id = "vm-${replaceStrings [ ":" ] [ "" ] mac}";
|
||||
inherit mac;
|
||||
macvtap = {
|
||||
link = hostLink;
|
||||
|
@ -82,9 +89,11 @@ in {
|
|||
);
|
||||
};
|
||||
|
||||
networking.renameInterfacesByMac = flip mapAttrs guestCfg.microvm.interfaces (_: {mac, ...}: mac);
|
||||
networking.renameInterfacesByMac = flip mapAttrs guestCfg.microvm.interfaces (_: { mac, ... }: mac);
|
||||
systemd.network.networks = flip concatMapAttrs guestCfg.microvm.interfaces (
|
||||
name: {mac, ...}: {
|
||||
name:
|
||||
{ mac, ... }:
|
||||
{
|
||||
"10-${name}".matchConfig = mkForce {
|
||||
MACAddress = mac;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue