1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/modules/retiolum.nix

76 lines
1.6 KiB
Nix
Raw Normal View History

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