2024-01-11 22:42:03 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
stateVersion,
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
minimal,
|
|
|
|
nodes,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
adguardhomedomain = "adguardhome.${config.secrets.secrets.global.domains.web}";
|
|
|
|
nextclouddomain = "nc.${config.secrets.secrets.global.domains.web}";
|
2024-01-12 15:47:43 +01:00
|
|
|
giteadomain = "git.${config.secrets.secrets.global.domains.web}";
|
2024-01-12 17:16:37 +01:00
|
|
|
vaultwardendomain = "pw.${config.secrets.secrets.global.domains.web}";
|
2024-01-18 00:39:25 +01:00
|
|
|
paperlessdomain = "ppl.${config.secrets.secrets.global.domains.web}";
|
2024-01-20 21:07:00 +01:00
|
|
|
immichdomain = "immich.${config.secrets.secrets.global.domains.web}";
|
2024-01-12 15:47:43 +01:00
|
|
|
ipOf = hostName: lib.net.cidr.host config.secrets.secrets.global.net.ips."${config.guests.${hostName}.nodeName}" config.secrets.secrets.global.net.privateSubnet;
|
2024-01-11 22:42:03 +01:00
|
|
|
in {
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
recommendedSetup = true;
|
2024-01-12 17:16:37 +01:00
|
|
|
upstreams.vaultwarden = {
|
|
|
|
servers."${ipOf "vaultwarden"}:3000" = {};
|
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
zone vaultwarden 64k ;
|
|
|
|
keepalive 5 ;
|
|
|
|
'';
|
|
|
|
};
|
2024-01-18 20:10:54 +01:00
|
|
|
|
2024-01-12 17:16:37 +01:00
|
|
|
virtualHosts.${vaultwardendomain} = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "web";
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://vaultwarden";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 1G ;
|
|
|
|
'';
|
|
|
|
};
|
2024-01-18 00:39:25 +01:00
|
|
|
|
2024-01-12 15:47:43 +01:00
|
|
|
upstreams.gitea = {
|
|
|
|
servers."${ipOf "gitea"}:3000" = {};
|
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
zone gitea 64k ;
|
|
|
|
keepalive 5 ;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
virtualHosts.${giteadomain} = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "web";
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://gitea";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 1G ;
|
|
|
|
'';
|
|
|
|
};
|
2024-01-18 00:39:25 +01:00
|
|
|
|
2024-01-20 21:07:00 +01:00
|
|
|
upstreams.immich = {
|
|
|
|
servers."${ipOf "immich"}:3000" = {};
|
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
zone gitea 64k ;
|
|
|
|
keepalive 5 ;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
virtualHosts.${immichdomain} = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "web";
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://immich";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 1G ;
|
|
|
|
deny all
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-01-11 22:42:03 +01:00
|
|
|
upstreams.adguardhome = {
|
2024-01-12 15:47:43 +01:00
|
|
|
servers."${ipOf "adguardhome"}:3000" = {};
|
2024-01-11 22:42:03 +01:00
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
zone adguardhome 64k ;
|
|
|
|
keepalive 5 ;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
virtualHosts.${adguardhomedomain} = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "web";
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://adguardhome";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
extraConfig = ''
|
|
|
|
allow 192.168.178.0/24;
|
|
|
|
deny all;
|
|
|
|
'';
|
|
|
|
};
|
2024-01-18 00:39:25 +01:00
|
|
|
upstreams.paperless = {
|
|
|
|
servers."${ipOf "paperless"}:3000" = {};
|
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
zone paperless 64k ;
|
|
|
|
keepalive 5 ;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
virtualHosts.${paperlessdomain} = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "web";
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://paperless";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
X-Frame-Options = "SAMEORIGIN";
|
|
|
|
};
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 4G ;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-01-11 22:42:03 +01:00
|
|
|
upstreams.nextcloud = {
|
2024-01-13 19:23:51 +01:00
|
|
|
servers."${ipOf "nextcloud"}:80" = {};
|
2024-01-11 22:42:03 +01:00
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
zone nextcloud 64k ;
|
|
|
|
keepalive 5 ;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
virtualHosts.${nextclouddomain} = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "web";
|
|
|
|
locations."/".proxyPass = "http://nextcloud";
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 4G ;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
guests = let
|
|
|
|
mkGuest = guestName: {
|
|
|
|
enablePanzer ? false,
|
|
|
|
enableRenaultFT ? false,
|
2024-01-15 02:13:46 +01:00
|
|
|
enableBunker ? false,
|
2024-01-18 00:39:25 +01:00
|
|
|
enableSharedPaperless ? false,
|
2024-01-11 22:42:03 +01:00
|
|
|
...
|
|
|
|
}: {
|
|
|
|
autostart = true;
|
|
|
|
zfs."/state" = {
|
|
|
|
pool = "rpool";
|
|
|
|
dataset = "local/guests/${guestName}";
|
|
|
|
};
|
|
|
|
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}";
|
|
|
|
};
|
2024-01-15 02:13:46 +01:00
|
|
|
zfs."/bunker" = lib.mkIf enableBunker {
|
|
|
|
pool = "panzer";
|
|
|
|
dataset = "bunker/guests/${guestName}";
|
|
|
|
};
|
2024-01-18 00:39:25 +01:00
|
|
|
zfs."/paperless" = lib.mkIf enableSharedPaperless {
|
|
|
|
pool = "panzer";
|
|
|
|
dataset = "bunker/shared/paperless";
|
|
|
|
};
|
2024-01-11 22:42:03 +01:00
|
|
|
modules = [
|
|
|
|
../../modules/config
|
|
|
|
../../modules/services/${guestName}.nix
|
|
|
|
{
|
|
|
|
node.secretsDir = ./secrets/${guestName};
|
|
|
|
systemd.network.networks."10-${config.guests.${guestName}.networking.mainLinkName}" = {
|
|
|
|
DHCP = lib.mkForce "no";
|
2024-01-13 16:07:55 +01:00
|
|
|
address = [
|
|
|
|
(
|
|
|
|
lib.net.cidr.hostCidr config.secrets.secrets.global.net.ips."${config.guests.${guestName}.nodeName}" config.secrets.secrets.global.net.privateSubnet
|
|
|
|
)
|
|
|
|
];
|
2024-01-11 22:42:03 +01:00
|
|
|
gateway = [(lib.net.cidr.host 1 config.secrets.secrets.global.net.privateSubnet)];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
#deadnix: skip
|
|
|
|
mkMicrovm = guestName: cfg: {
|
|
|
|
${guestName} =
|
|
|
|
mkGuest guestName cfg
|
|
|
|
// {
|
|
|
|
backend = "microvm";
|
|
|
|
microvm = {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
macvtap = "lan";
|
|
|
|
baseMac = config.repo.secrets.local.networking.interfaces.lan.mac;
|
|
|
|
};
|
|
|
|
extraSpecialArgs = {
|
|
|
|
inherit (inputs.self) nodes;
|
|
|
|
inherit (inputs.self.pkgs.x86_64-linux) lib;
|
|
|
|
inherit inputs minimal stateVersion;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
mkContainer = guestName: cfg: {
|
|
|
|
${guestName} =
|
|
|
|
mkGuest guestName cfg
|
|
|
|
// {
|
|
|
|
backend = "container";
|
|
|
|
container.macvlan = "lan";
|
|
|
|
extraSpecialArgs = {
|
|
|
|
inherit lib nodes inputs minimal stateVersion;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{}
|
|
|
|
// mkContainer "adguardhome" {}
|
2024-01-12 17:16:37 +01:00
|
|
|
// mkContainer "vaultwarden" {}
|
2024-01-13 19:23:51 +01:00
|
|
|
// mkContainer "ddclient" {}
|
2024-01-11 22:42:03 +01:00
|
|
|
// mkContainer "nextcloud" {
|
|
|
|
enablePanzer = true;
|
|
|
|
}
|
2024-01-18 00:39:25 +01:00
|
|
|
// mkContainer "paperless" {
|
|
|
|
enableSharedPaperless = true;
|
|
|
|
}
|
2024-01-12 15:47:43 +01:00
|
|
|
// mkContainer "gitea" {
|
|
|
|
enablePanzer = true;
|
|
|
|
}
|
2024-01-20 21:07:00 +01:00
|
|
|
// mkContainer "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;
|
2024-01-11 22:42:03 +01:00
|
|
|
};
|
|
|
|
}
|