2024-01-11 22:42:03 +01:00
|
|
|
{
|
|
|
|
config,
|
2024-12-22 00:10:37 +01:00
|
|
|
globals,
|
2024-01-11 22:42:03 +01:00
|
|
|
stateVersion,
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
minimal,
|
|
|
|
...
|
2024-07-26 22:12:48 +02:00
|
|
|
}:
|
|
|
|
{
|
2024-03-14 20:07:10 +01:00
|
|
|
|
2024-07-26 22:12:48 +02:00
|
|
|
guests =
|
|
|
|
let
|
|
|
|
mkGuest =
|
|
|
|
guestName:
|
|
|
|
{
|
|
|
|
enablePanzer ? false,
|
|
|
|
enableRenaultFT ? false,
|
|
|
|
enableBunker ? false,
|
|
|
|
enableSharedPaperless ? false,
|
2024-12-22 00:10:37 +01:00
|
|
|
vlans ? [ "services" ],
|
2024-07-26 22:12:48 +02:00
|
|
|
...
|
|
|
|
}:
|
2024-01-11 22:42:03 +01:00
|
|
|
{
|
2024-07-26 22:12:48 +02:00
|
|
|
autostart = true;
|
|
|
|
zfs."/state" = {
|
|
|
|
pool = "rpool";
|
|
|
|
dataset = "local/guests/${guestName}";
|
2024-01-11 22:42:03 +01:00
|
|
|
};
|
2024-07-26 22:12:48 +02:00
|
|
|
zfs."/persist" = {
|
|
|
|
pool = "rpool";
|
|
|
|
dataset = "safe/guests/${guestName}";
|
|
|
|
};
|
|
|
|
zfs."/panzer" = lib.mkIf enablePanzer {
|
|
|
|
pool = "panzer";
|
|
|
|
dataset = "safe/guests/${guestName}";
|
|
|
|
};
|
|
|
|
zfs."/renaultft" = lib.mkIf enableRenaultFT {
|
|
|
|
pool = "renaultft";
|
|
|
|
dataset = "safe/guests/${guestName}";
|
|
|
|
};
|
|
|
|
# kinda not necesarry should be removed on next reimaging
|
|
|
|
zfs."/bunker" = lib.mkIf enableBunker {
|
|
|
|
pool = "panzer";
|
|
|
|
dataset = "bunker/guests/${guestName}";
|
|
|
|
};
|
|
|
|
zfs."/paperless" = lib.mkIf enableSharedPaperless {
|
|
|
|
pool = "panzer";
|
|
|
|
dataset = "bunker/shared/paperless";
|
|
|
|
};
|
|
|
|
modules = [
|
|
|
|
../../config/basic
|
|
|
|
../../config/services/${guestName}.nix
|
|
|
|
{
|
|
|
|
node.secretsDir = config.node.secretsDir + "/${guestName}";
|
2025-01-07 21:23:06 +01:00
|
|
|
networking.nftables.firewall.zones.untrusted.interfaces = [ "mv-services" ];
|
2024-12-22 00:10:37 +01:00
|
|
|
systemd.network.networks = lib.mkIf (globals.services.${guestName}.ip != null) (
|
|
|
|
lib.listToAttrs (
|
|
|
|
lib.flip map vlans (
|
|
|
|
name:
|
2024-12-24 14:54:17 +01:00
|
|
|
lib.nameValuePair "10-mv-${name}" {
|
2024-12-22 00:10:37 +01:00
|
|
|
matchConfig.Name = "mv-${name}";
|
2024-12-24 14:54:17 +01:00
|
|
|
DHCP = lib.mkForce "no";
|
2024-12-22 00:10:37 +01:00
|
|
|
address = [
|
|
|
|
(lib.net.cidr.hostCidr globals.services.${guestName}.ip globals.net.vlans.${name}.cidrv4)
|
|
|
|
(lib.net.cidr.hostCidr globals.services.${guestName}.ip globals.net.vlans.${name}.cidrv6)
|
|
|
|
];
|
2025-01-07 21:23:06 +01:00
|
|
|
gateway = lib.optionals globals.net.vlans.${name}.internet [
|
2024-12-22 19:00:21 +01:00
|
|
|
(lib.net.cidr.host 1 globals.net.vlans.${name}.cidrv4)
|
|
|
|
(lib.net.cidr.host 1 globals.net.vlans.${name}.cidrv6)
|
2024-12-22 00:10:37 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2024-07-26 22:12:48 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2024-01-11 22:42:03 +01:00
|
|
|
|
2024-07-26 22:12:48 +02:00
|
|
|
mkMicrovm = guestName: cfg: {
|
|
|
|
${guestName} = mkGuest guestName cfg // {
|
2024-01-11 22:42:03 +01:00
|
|
|
backend = "microvm";
|
|
|
|
microvm = {
|
|
|
|
system = "x86_64-linux";
|
2024-12-22 19:00:21 +01:00
|
|
|
interfaces.lan-services = { };
|
2024-01-21 00:43:50 +01:00
|
|
|
baseMac = config.secrets.secrets.local.networking.interfaces.lan01.mac;
|
2024-01-11 22:42:03 +01:00
|
|
|
};
|
|
|
|
extraSpecialArgs = {
|
2024-12-20 20:40:27 +01:00
|
|
|
inherit (inputs.self) nodes globals;
|
2024-01-11 22:42:03 +01:00
|
|
|
inherit (inputs.self.pkgs.x86_64-linux) lib;
|
|
|
|
inherit inputs minimal stateVersion;
|
|
|
|
};
|
|
|
|
};
|
2024-07-26 22:12:48 +02:00
|
|
|
};
|
2024-01-11 22:42:03 +01:00
|
|
|
|
2024-12-22 00:10:37 +01:00
|
|
|
mkContainer =
|
|
|
|
guestName:
|
|
|
|
{
|
|
|
|
vlans ? [ "services" ],
|
|
|
|
...
|
|
|
|
}@cfg:
|
|
|
|
{
|
|
|
|
${guestName} = mkGuest guestName cfg // {
|
|
|
|
backend = "container";
|
|
|
|
container.macvlans = lib.flip map vlans (x: "lan-${x}:mv-${x}");
|
|
|
|
extraSpecialArgs = {
|
|
|
|
inherit (inputs.self) nodes globals;
|
|
|
|
inherit (inputs.self.pkgs.x86_64-linux) lib;
|
|
|
|
inherit inputs minimal stateVersion;
|
|
|
|
};
|
2024-01-11 22:42:03 +01:00
|
|
|
};
|
|
|
|
};
|
2024-07-26 22:12:48 +02:00
|
|
|
in
|
|
|
|
{ }
|
|
|
|
// mkContainer "oauth2-proxy" { }
|
|
|
|
// mkContainer "vaultwarden" { }
|
|
|
|
// mkContainer "ddclient" { }
|
2025-01-08 17:46:44 +01:00
|
|
|
// mkContainer "ollama" {
|
|
|
|
enableRenaultFT = true;
|
|
|
|
}
|
2024-07-26 22:12:48 +02:00
|
|
|
// mkContainer "murmur" { }
|
2024-09-01 19:51:52 +02:00
|
|
|
// mkContainer "homebox" { }
|
2024-08-23 00:30:11 +02:00
|
|
|
// mkContainer "invidious" { }
|
2024-07-26 22:12:48 +02:00
|
|
|
// mkContainer "ttrss" { }
|
|
|
|
// mkContainer "firefly" { }
|
|
|
|
// mkContainer "yourspotify" { }
|
|
|
|
// mkContainer "netbird" { }
|
2024-09-01 15:53:19 +02:00
|
|
|
// mkContainer "blog" { }
|
2024-07-26 22:12:48 +02:00
|
|
|
// mkContainer "kanidm" { }
|
2025-01-07 21:23:06 +01:00
|
|
|
// mkContainer "homeassistant" {
|
|
|
|
vlans = [
|
|
|
|
"services"
|
|
|
|
"devices"
|
|
|
|
"iot"
|
|
|
|
];
|
|
|
|
}
|
2024-07-26 22:12:48 +02:00
|
|
|
// mkContainer "nextcloud" { enablePanzer = true; }
|
|
|
|
// mkContainer "paperless" { enableSharedPaperless = true; }
|
|
|
|
// mkContainer "forgejo" { enablePanzer = true; }
|
|
|
|
// mkMicrovm "immich" { enablePanzer = true; }
|
2024-01-11 22:42:03 +01:00
|
|
|
// mkContainer "samba" {
|
|
|
|
enablePanzer = true;
|
|
|
|
enableRenaultFT = true;
|
2024-01-18 00:39:25 +01:00
|
|
|
enableBunker = true;
|
|
|
|
enableSharedPaperless = true;
|
2025-01-07 21:23:06 +01:00
|
|
|
vlans = [
|
|
|
|
"home"
|
|
|
|
];
|
2024-01-11 22:42:03 +01:00
|
|
|
};
|
|
|
|
}
|