mirror of
https://github.com/kmein/niveum
synced 2026-03-16 18:21:07 +01:00
88 lines
2.0 KiB
Nix
88 lines
2.0 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
with lib;
|
|
let
|
|
stockholm-systems =
|
|
let systemsDir = <stockholm> + "/krebs/1systems";
|
|
in genAttrs
|
|
(attrNames (filterAttrs (_: value: value == "directory") (builtins.readDir systemsDir)))
|
|
(name: import <nixpkgs/nixos> {
|
|
configuration = import (systemsDir + "/${name}/config.nix");
|
|
});
|
|
|
|
hostsPackage = stockholm-systems.filebitch.config.krebs.tinc.retiolum.hostsPackage;
|
|
|
|
netname = "retiolum";
|
|
cfg = config.networking.retiolum;
|
|
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
|
|
'';
|
|
};
|
|
|
|
# environment.etc."tinc/retiolum".source = hostsPackage;
|
|
|
|
systemd.services."tinc.${netname}" = {
|
|
preStart = ''
|
|
set -eu
|
|
|
|
mkdir -p /etc/tinc/${netname}/hosts/
|
|
cp ${hostsPackage}/* /etc/tinc/${netname}/hosts/
|
|
'';
|
|
};
|
|
|
|
networking.extraHosts =
|
|
# TODO generate from stockholm
|
|
builtins.readFile (toString <retiolum/etc.hosts>);
|
|
|
|
environment.systemPackages =
|
|
[ config.services.tinc.networks.${netname}.package ];
|
|
|
|
networking.firewall = {
|
|
allowedTCPPorts = [ 655 ];
|
|
allowedUDPPorts = [ 655 ];
|
|
};
|
|
#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
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|