1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 18:21:07 +01:00
Files
niveum/modules/retiolum.nix
2019-02-05 22:09:08 +01:00

76 lines
1.6 KiB
Nix

{ config, pkgs, lib, ... }:
with lib;
let
netname = "retiolum";
cfg = config.networking.retiolum;
retiolum = pkgs.fetchFromGitHub {
owner = "krebs";
repo = netname;
rev = "3ffcc41287434619a113ef3065ca5bd7d41478a5";
sha256 = "1svz2gym89y19xv8sy6nda59as9cjckf26skrbqap6kb5zrvm3v2";
};
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
'';
};
};
config = {
services.tinc.networks.${netname} = {
name = cfg.nodename;
extraConfig = ''
LocalDiscovery = yes
AutoConnect = yes
'';
};
systemd.services."tinc.${netname}" = {
preStart = ''
cp -R ${retiolum}/hosts /etc/tinc/retiolum/ || true
'';
};
networking.extraHosts = builtins.readFile (toString "${retiolum}/etc.hosts");
environment.systemPackages = [ config.services.tinc.networks.${netname}.package ];
networking.firewall.allowedTCPPorts = [ 655 ];
networking.firewall.allowedUDPPorts = [ 655 ];
#services.netdata.portcheck.checks.tinc.port = 655;
systemd.network.enable = true;
systemd.network.networks = {
"${netname}".extraConfig = ''
[Match]
Name = tinc.${netname}
[Network]
Address=${cfg.ipv4}/12
Address=${cfg.ipv6}/16
'';
};
};
}