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"}"
12 install.target = lib.mkDefault "\"\${NIXOS_TARGET:-root@${config.networking.hostName}.sp}\"";
14 "10.0.0.1" = [ "mermet.sp" ];
15 "10.0.0.2" = [ "losurdo.sp" ];
16 "10.0.0.3" = [ "oignon.sp" ];
17 "10.0.0.4" = [ "patate.sp" ];
18 "10.0.0.5" = [ "carotte.sp" ];
19 "10.0.0.6" = [ "aubergine.sp" ];
20 "10.0.0.7" = [ "courge.sp" ];
22 services.nebula.networks.${domain} = {
24 ca = lib.mkDefault (./. + "/${domain}/ca.crt");
25 cert = lib.mkDefault (inputs.self + "/share/nebula/${domain}/${hostName}.crt");
26 key = "/run/credentials/nebula@${domain}.service/${hostName}.key";
27 listen.host = lib.mkDefault "0.0.0.0";
28 tun.device = lib.mkDefault "neb-sourcephile";
30 "10.0.0.1" = [ "mermet.${domain}:10001" ];
31 "10.0.0.2" = [ "losurdo.${domain}:10002" ];
42 { port = "any"; proto = "icmp"; groups = [ "sourcephile" "intra" ]; }
45 { port = "any"; proto = "icmp"; groups = [ "sourcephile" "intra" ]; }
53 default_timeout = "10m";
57 level = lib.mkDefault "info";
59 pki.disconnect_invalid = true;
66 listen = "127.0.0.1:8080";
68 namespace = "prometheusns";
71 message_metrics = false;
72 lighthouse_metrics = false;
77 networking.nftables.ruleset = ''
80 udp dport ${port} counter accept comment "Nebula ${domain}"
83 udp sport ${port} counter accept comment "Nebula ${domain}"
86 udp dport ${port} counter accept comment "Nebula ${domain}"
89 udp sport ${port} counter accept comment "Nebula ${domain}"
91 chain input-${iface} {
92 tcp dport ssh counter accept comment "SSH"
93 udp dport 60000-60100 counter accept comment "Mosh"
95 chain output-${iface} {
96 tcp dport ssh counter accept comment "SSH"
97 udp dport 60000-60100 counter accept comment "Mosh"
100 iifname ${iface} jump input-${iface}
101 iifname ${iface} log level warn prefix "input-${iface}: " counter drop
104 oifname ${iface} jump output-${iface}
105 oifname ${iface} log level warn prefix "output-${iface}: " counter drop
109 networking.networkmanager.unmanaged = [ iface ];