2019-01-30 13:26:06 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
2019-02-05 20:21:41 +01:00
|
|
|
|
2019-01-30 13:26:06 +01:00
|
|
|
with lib;
|
2019-02-05 20:21:41 +01:00
|
|
|
|
2019-01-30 13:26:06 +01:00
|
|
|
let
|
|
|
|
|
netname = "retiolum";
|
|
|
|
|
cfg = config.networking.retiolum;
|
2019-02-05 20:21:41 +01:00
|
|
|
|
|
|
|
|
retiolum = pkgs.fetchFromGitHub {
|
|
|
|
|
owner = "krebs";
|
|
|
|
|
repo = netname;
|
2020-08-17 16:01:39 +02:00
|
|
|
rev = "76e8de36d4ac06bcfaf551946aa2f6a41d9e6555";
|
|
|
|
|
sha256 = "0yhmmvg6gm5yxs1gzszl19bs6y302yjg81a7sckfglwzcql3q0wf";
|
2019-02-05 20:21:41 +01:00
|
|
|
};
|
2019-01-30 13:26:06 +01:00
|
|
|
in {
|
|
|
|
|
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
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
2019-02-05 20:21:41 +01:00
|
|
|
|
2019-01-30 13:26:06 +01:00
|
|
|
config = {
|
2019-02-05 20:21:41 +01:00
|
|
|
|
2019-01-30 13:26:06 +01:00
|
|
|
services.tinc.networks.${netname} = {
|
|
|
|
|
name = cfg.nodename;
|
|
|
|
|
extraConfig = ''
|
|
|
|
|
LocalDiscovery = yes
|
|
|
|
|
AutoConnect = yes
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
systemd.services."tinc.${netname}" = {
|
|
|
|
|
preStart = ''
|
2020-10-18 17:27:43 +02:00
|
|
|
cp -R ${toString <retiolum/hosts>} /etc/tinc/retiolum/ || true
|
2019-01-30 13:26:06 +01:00
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-10 17:37:25 +02:00
|
|
|
networking.extraHosts =
|
2020-10-18 17:27:43 +02:00
|
|
|
builtins.readFile (toString <retiolum/etc.hosts>);
|
2019-02-05 20:21:41 +01:00
|
|
|
|
2020-06-10 17:37:25 +02:00
|
|
|
environment.systemPackages =
|
|
|
|
|
[ config.services.tinc.networks.${netname}.package ];
|
2019-02-05 20:21:41 +01:00
|
|
|
|
2019-11-19 08:43:14 +01:00
|
|
|
networking.firewall = {
|
|
|
|
|
allowedTCPPorts = [ 655 ];
|
|
|
|
|
allowedUDPPorts = [ 655 ];
|
|
|
|
|
};
|
2019-02-05 20:21:41 +01:00
|
|
|
#services.netdata.portcheck.checks.tinc.port = 655;
|
2019-01-30 13:26:06 +01:00
|
|
|
|
2019-11-19 08:43:14 +01:00
|
|
|
systemd.network = {
|
|
|
|
|
enable = true;
|
|
|
|
|
networks = {
|
|
|
|
|
"${netname}".extraConfig = ''
|
|
|
|
|
[Match]
|
|
|
|
|
Name = tinc.${netname}
|
2019-02-05 20:21:41 +01:00
|
|
|
|
2019-11-19 08:43:14 +01:00
|
|
|
[Network]
|
|
|
|
|
Address=${cfg.ipv4}/12
|
|
|
|
|
Address=${cfg.ipv6}/16
|
|
|
|
|
'';
|
|
|
|
|
};
|
2019-01-30 13:26:06 +01:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|