2023-03-26 19:24:38 +02:00
|
|
|
{
|
|
|
|
|
config,
|
|
|
|
|
pkgs,
|
|
|
|
|
lib,
|
|
|
|
|
...
|
|
|
|
|
}:
|
2025-12-27 22:22:54 +01:00
|
|
|
with lib;
|
|
|
|
|
let
|
2023-03-26 19:24:38 +02:00
|
|
|
netname = "retiolum";
|
|
|
|
|
cfg = config.networking.retiolum;
|
2025-12-27 22:22:54 +01:00
|
|
|
in
|
|
|
|
|
{
|
2023-03-26 19:24:38 +02:00
|
|
|
options = {
|
|
|
|
|
networking.retiolum.ipv4 = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = ''
|
|
|
|
|
own ipv4 address
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
networking.retiolum.ipv6 = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = ''
|
|
|
|
|
own ipv6 address
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
networking.retiolum.nodename = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = config.networking.hostName;
|
|
|
|
|
description = ''
|
|
|
|
|
tinc network name
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
services.tinc.networks.${netname} = {
|
|
|
|
|
name = cfg.nodename;
|
2025-12-27 22:22:54 +01:00
|
|
|
hosts = builtins.mapAttrs (name: _: builtins.readFile "${<retiolum/hosts>}/${name}") (
|
|
|
|
|
builtins.readDir <retiolum/hosts>
|
|
|
|
|
);
|
2023-03-26 19:24:38 +02:00
|
|
|
rsaPrivateKeyFile = toString <system-secrets/retiolum.key>;
|
|
|
|
|
ed25519PrivateKeyFile = toString <system-secrets/retiolum.ed25519>;
|
|
|
|
|
extraConfig = ''
|
|
|
|
|
LocalDiscovery = yes
|
|
|
|
|
AutoConnect = yes
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
networking.extraHosts = builtins.readFile (toString <retiolum/etc.hosts>);
|
|
|
|
|
|
2025-12-27 22:22:54 +01:00
|
|
|
environment.systemPackages = [ config.services.tinc.networks.${netname}.package ];
|
2023-03-26 19:24:38 +02:00
|
|
|
|
|
|
|
|
networking.firewall = {
|
2025-12-27 22:22:54 +01:00
|
|
|
allowedTCPPorts = [ 655 ];
|
|
|
|
|
allowedUDPPorts = [ 655 ];
|
2023-03-26 19:24:38 +02:00
|
|
|
};
|
|
|
|
|
#services.netdata.portcheck.checks.tinc.port = 655;
|
|
|
|
|
|
|
|
|
|
systemd.network = {
|
|
|
|
|
enable = true;
|
|
|
|
|
networks = {
|
|
|
|
|
"${netname}".extraConfig = ''
|
|
|
|
|
[Match]
|
|
|
|
|
Name = tinc.${netname}
|
|
|
|
|
|
|
|
|
|
[Network]
|
|
|
|
|
Address=${cfg.ipv4}/12
|
|
|
|
|
Address=${cfg.ipv6}/16
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|