services/enthalpy: dedup enthalpy configuration

This commit is contained in:
Lu Wang 2024-12-08 18:55:05 +08:00
parent a4549f7052
commit f1ad024cd7
Signed by: rebmit
SSH key fingerprint: SHA256:3px8QV1zEerIrEWHaqtH5rR9kjetyRST5EipOPrd+bU
11 changed files with 83 additions and 72 deletions

View file

@ -6,20 +6,11 @@
}:
{
imports = with profiles; [
services.enthalpy
services.enthalpy.customer
];
services.enthalpy.ipsec.interfaces = [ "enp2s0" ];
networking.netns.enthalpy.forwardPorts = [
{
protocol = "tcp";
netns = "default";
source = "[::]:${toString config.networking.ports.ssh}";
target = "[::]:${toString config.networking.ports.ssh}";
}
];
systemd.network = {
enable = true;
wait-online.anyInterface = true;

View file

@ -1,34 +1,17 @@
{
config,
profiles,
lib,
...
}:
{
imports = with profiles; [
services.enthalpy
services.enthalpy.customer-dualstack
services.enthalpy.fw-proxy
];
services.enthalpy = {
ipsec.interfaces = [ "enp14s0" ];
clat = {
enable = true;
segment = lib.singleton "fde3:3be3:a244:2676::2";
};
gost.enable = true;
};
systemd.services.nix-daemon = {
serviceConfig = config.networking.netns.enthalpy.serviceConfig;
after = [ "netns-enthalpy.service" ];
requires = [ "netns-enthalpy.service" ];
};
systemd.services."user@${toString config.users.users.rebmit.uid}" = {
overrideStrategy = "asDropin";
serviceConfig = config.networking.netns.enthalpy.serviceConfig;
after = [ "netns-enthalpy.service" ];
requires = [ "netns-enthalpy.service" ];
clat.segment = lib.singleton "fde3:3be3:a244:2676::2";
};
systemd.network = {

View file

@ -1,12 +1,12 @@
{
config,
profiles,
lib,
...
}:
{
imports = with profiles; [
services.enthalpy
services.enthalpy.customer-dualstack
services.enthalpy.fw-proxy
];
services.enthalpy = {
@ -14,24 +14,7 @@
interfaces = [ "wlan0" ];
whitelist = [ "rebmit's edge network" ];
};
clat = {
enable = true;
segment = lib.singleton "fde3:3be3:a244:2676::2";
};
gost.enable = true;
};
systemd.services.nix-daemon = {
serviceConfig = config.networking.netns.enthalpy.serviceConfig;
after = [ "netns-enthalpy.service" ];
requires = [ "netns-enthalpy.service" ];
};
systemd.services."user@${toString config.users.users.rebmit.uid}" = {
overrideStrategy = "asDropin";
serviceConfig = config.networking.netns.enthalpy.serviceConfig;
after = [ "netns-enthalpy.service" ];
requires = [ "netns-enthalpy.service" ];
clat.segment = lib.singleton "fde3:3be3:a244:2676::2";
};
systemd.network = {

View file

@ -1,28 +1,10 @@
{
profiles,
data,
...
}:
{ profiles, ... }:
{
imports = with profiles; [
services.enthalpy
services.enthalpy.transit-dualstack
];
services.enthalpy = {
ipsec.interfaces = [ "enp3s0" ];
exit = {
enable = true;
prefix = [
{
type = "bird";
destination = "::/0";
source = data.enthalpy_network_prefix;
}
];
};
srv6.enable = true;
nat64.enable = true;
};
services.enthalpy.ipsec.interfaces = [ "enp3s0" ];
networking.nftables.tables.nat = {
family = "inet";

View file

@ -73,7 +73,7 @@ in
networking.nftables = {
enable = true;
tables.enthalpy4 = {
tables.enthalpy-nat64 = {
family = "ip";
content = ''
chain forward {

View file

@ -3,6 +3,7 @@
data,
hostData,
self,
lib,
...
}:
{
@ -37,4 +38,13 @@
routerId = hostData.enthalpy_node_id;
};
};
networking.netns.enthalpy.forwardPorts = lib.optionals config.services.openssh.enable [
{
protocol = "tcp";
netns = "default";
source = "[::]:${toString config.networking.ports.ssh}";
target = "[::]:${toString config.networking.ports.ssh}";
}
];
}

View file

@ -0,0 +1,8 @@
{ profiles, ... }:
{
imports = [
profiles.services.enthalpy.customer
];
services.enthalpy.clat.enable = true;
}

View file

@ -0,0 +1,6 @@
{ profiles, ... }:
{
imports = [
profiles.services.enthalpy.common
];
}

View file

@ -0,0 +1,17 @@
{ config, ... }:
{
services.enthalpy.gost.enable = true;
systemd.services.nix-daemon = {
inherit (config.networking.netns.enthalpy) serviceConfig;
after = [ "netns-enthalpy.service" ];
requires = [ "netns-enthalpy.service" ];
};
systemd.services."user@${toString config.users.users.rebmit.uid}" = {
inherit (config.networking.netns.enthalpy) serviceConfig;
overrideStrategy = "asDropin";
after = [ "netns-enthalpy.service" ];
requires = [ "netns-enthalpy.service" ];
};
}

View file

@ -0,0 +1,11 @@
{ profiles, ... }:
{
imports = [
profiles.services.enthalpy.transit
];
services.enthalpy = {
srv6.enable = true;
nat64.enable = true;
};
}

View file

@ -0,0 +1,20 @@
{
profiles,
lib,
data,
...
}:
{
imports = [
profiles.services.enthalpy.common
];
services.enthalpy.exit = {
enable = true;
prefix = lib.singleton {
type = "bird";
destination = "::/0";
source = data.enthalpy_network_prefix;
};
};
}