1 { pkgs, lib, config, inputs, hostName, ... }:
3 domain = "sourcephile.fr";
4 port = toString config.services.nebula.networks.${domain}.listen.port;
5 iface = config.services.nebula.networks.${domain}.tun.device;
8 environment.systemPackages = with pkgs; [ nebula ];
9 systemd.services."nebula@${domain}".serviceConfig.LoadCredentialEncrypted = [
10 "${hostName}.key:${inputs.self + "/hosts/${hostName}/nebula/${hostName}.key.cred"}"
13 "10.0.0.1" = [ "mermet.sp" ];
14 "10.0.0.2" = [ "losurdo.sp" ];
15 "10.0.0.3" = [ "oignon.sp" ];
16 "10.0.0.4" = [ "patate.sp" ];
17 "10.0.0.5" = [ "carotte.sp" ];
18 "10.0.0.6" = [ "aubergine.sp" ];
19 "10.0.0.7" = [ "courge.sp" ];
21 services.nebula.networks.${domain} = {
23 ca = ./. + "/${domain}/ca.crt";
24 cert = ./. + "/${domain}/${hostName}.crt";
25 key = "/run/credentials/nebula@${domain}.service/${hostName}.key";
26 listen.host = lib.mkDefault "0.0.0.0";
27 tun.device = lib.mkDefault "neb-sourcephile";
29 "10.0.0.1" = [ "mermet.${domain}:10001" ];
30 "10.0.0.2" = [ "losurdo.${domain}:10002" ];
41 { port = "any"; proto = "icmp"; groups = [ "sourcephile" "intra" ]; }
44 { port = "any"; proto = "icmp"; groups = [ "sourcephile" "intra" ]; }
52 default_timeout = "10m";
56 level = lib.mkDefault "info";
58 pki.disconnect_invalid = true;
65 listen = "127.0.0.1:8080";
67 namespace = "prometheusns";
70 message_metrics = false;
71 lighthouse_metrics = false;
76 networking.nftables.ruleset = ''
79 udp dport ${port} counter accept comment "Nebula ${domain}"
82 udp sport ${port} counter accept comment "Nebula ${domain}"
85 udp dport ${port} counter accept comment "Nebula ${domain}"
88 udp sport ${port} counter accept comment "Nebula ${domain}"
90 chain input-${iface} {
91 tcp dport ssh counter accept comment "SSH"
92 udp dport 60000-60100 counter accept comment "Mosh"
94 chain output-${iface} {
95 tcp dport ssh counter accept comment "SSH"
96 udp dport 60000-60100 counter accept comment "Mosh"
99 iifname ${iface} jump input-${iface}
100 iifname ${iface} log level warn prefix "input-${iface}: " counter drop
103 oifname ${iface} jump output-${iface}
104 oifname ${iface} log level warn prefix "output-${iface}: " counter drop