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; [ imports = with profiles; [
services.enthalpy services.enthalpy.customer
]; ];
services.enthalpy.ipsec.interfaces = [ "enp2s0" ]; 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 = { systemd.network = {
enable = true; enable = true;
wait-online.anyInterface = true; wait-online.anyInterface = true;

View file

@ -1,34 +1,17 @@
{ {
config,
profiles, profiles,
lib, lib,
... ...
}: }:
{ {
imports = with profiles; [ imports = with profiles; [
services.enthalpy services.enthalpy.customer-dualstack
services.enthalpy.fw-proxy
]; ];
services.enthalpy = { services.enthalpy = {
ipsec.interfaces = [ "enp14s0" ]; ipsec.interfaces = [ "enp14s0" ];
clat = { clat.segment = lib.singleton "fde3:3be3:a244:2676::2";
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" ];
}; };
systemd.network = { systemd.network = {

View file

@ -1,12 +1,12 @@
{ {
config,
profiles, profiles,
lib, lib,
... ...
}: }:
{ {
imports = with profiles; [ imports = with profiles; [
services.enthalpy services.enthalpy.customer-dualstack
services.enthalpy.fw-proxy
]; ];
services.enthalpy = { services.enthalpy = {
@ -14,24 +14,7 @@
interfaces = [ "wlan0" ]; interfaces = [ "wlan0" ];
whitelist = [ "rebmit's edge network" ]; whitelist = [ "rebmit's edge network" ];
}; };
clat = { clat.segment = lib.singleton "fde3:3be3:a244:2676::2";
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" ];
}; };
systemd.network = { systemd.network = {

View file

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

View file

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

View file

@ -3,6 +3,7 @@
data, data,
hostData, hostData,
self, self,
lib,
... ...
}: }:
{ {
@ -37,4 +38,13 @@
routerId = hostData.enthalpy_node_id; 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;
};
};
}