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;
9 environment.systemPackages = with pkgs; [ nebula ];
10 systemd.services."nebula@${domain}".serviceConfig.LoadCredentialEncrypted = [
11 "${hostName}.key:${inputs.self + "/hosts/${hostName}/nebula/${hostName}.key.cred"}"
13 install.target = lib.mkDefault "\"\${NIXOS_TARGET:-root@${config.networking.hostName}.sp}\"";
15 "${IPv4Prefix}.1" = [ "mermet.sp" ];
16 "${IPv4Prefix}.2" = [ "losurdo.sp" ];
17 "${IPv4Prefix}.3" = [ "oignon.sp" ];
18 "${IPv4Prefix}.4" = [ "patate.sp" ];
19 "${IPv4Prefix}.5" = [ "carotte.sp" ];
20 "${IPv4Prefix}.6" = [ "aubergine.sp" ];
21 "${IPv4Prefix}.7" = [ "courge.sp" ];
23 services.nebula.networks.${domain} = {
25 ca = lib.mkDefault (./. + "/${domain}/ca.crt");
26 cert = lib.mkDefault (inputs.self + "/share/nebula/${domain}/${hostName}.crt");
27 key = "/run/credentials/nebula@${domain}.service/${hostName}.key";
28 listen.host = lib.mkDefault "0.0.0.0";
29 tun.device = lib.mkDefault "neb-sourcephile";
31 "${IPv4Prefix}.1" = [ "mermet.${domain}:10001" ];
32 "${IPv4Prefix}.2" = [ "losurdo.${domain}:10002" ];
43 { port = "any"; proto = "icmp"; groups = [ "sourcephile" "intra" ]; }
46 { port = "any"; proto = "icmp"; groups = [ "sourcephile" "intra" ]; }
54 default_timeout = "10m";
58 level = lib.mkDefault "info";
60 pki.disconnect_invalid = true;
67 listen = "127.0.0.1:8080";
69 namespace = "prometheusns";
72 message_metrics = false;
73 lighthouse_metrics = false;
78 networking.nftables.ruleset = ''
81 udp dport ${port} counter accept comment "Nebula ${domain}"
84 udp sport ${port} counter accept comment "Nebula ${domain}"
87 udp dport ${port} counter accept comment "Nebula ${domain}"
90 udp sport ${port} counter accept comment "Nebula ${domain}"
92 chain input-${iface} {
93 tcp dport ssh counter accept comment "SSH"
94 udp dport 60000-60100 counter accept comment "Mosh"
96 chain output-${iface} {
97 tcp dport ssh counter accept comment "SSH"
98 udp dport 60000-60100 counter accept comment "Mosh"
101 iifname ${iface} jump input-${iface}
102 iifname ${iface} log level warn prefix "input-${iface}: " counter drop
105 oifname ${iface} jump output-${iface}
106 oifname ${iface} log level warn prefix "output-${iface}: " counter drop
110 networking.networkmanager.unmanaged = [ iface ];
111 services.fail2ban.ignoreIP = [
112 "${IPv4Prefix}.1" # mermet.sp
113 "${IPv4Prefix}.2" # losurdo.sp
114 "${IPv4Prefix}.3" # oignon.sp