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}" = {
11 stopIfChanged = false;
12 serviceConfig.LoadCredentialEncrypted = [
13 "${hostName}.key:${builtins.path { path = inputs.self + "/hosts/${hostName}/nebula/${hostName}.key.cred"; }}"
16 install.target = lib.mkDefault "\"\${NIXOS_TARGET:-root@${config.networking.hostName}.sp}\"";
18 "${IPv4Prefix}.1" = [ "mermet.sp" ];
19 "${IPv4Prefix}.2" = [ "losurdo.sp" ];
20 "${IPv4Prefix}.3" = [ "oignon.sp" ];
21 "${IPv4Prefix}.4" = [ "patate.sp" ];
22 "${IPv4Prefix}.5" = [ "carotte.sp" ];
23 "${IPv4Prefix}.6" = [ "aubergine.sp" ];
24 "${IPv4Prefix}.7" = [ "courge.sp" ];
26 services.nebula.networks.${domain} = {
28 ca = lib.mkDefault (./. + "/${domain}/ca.crt");
29 cert = lib.mkDefault (builtins.path { path = inputs.self + "/share/nebula/${domain}/${hostName}.crt"; });
30 key = "/run/credentials/nebula@${domain}.service/${hostName}.key";
31 listen.host = lib.mkDefault "0.0.0.0";
32 tun.device = lib.mkDefault "neb-sourcephile";
34 "${IPv4Prefix}.1" = [ "mermet.${domain}:10001" ];
35 "${IPv4Prefix}.2" = [ "losurdo.${domain}:10002" ];
46 { port = "any"; proto = "icmp"; groups = [ "sourcephile" "intra" ]; }
49 { port = "any"; proto = "icmp"; groups = [ "sourcephile" "intra" ]; }
57 default_timeout = "10m";
61 level = lib.mkDefault "info";
63 pki.disconnect_invalid = true;
70 listen = "127.0.0.1:8080";
72 namespace = "prometheusns";
75 message_metrics = false;
76 lighthouse_metrics = false;
81 networking.nftables.ruleset = ''
84 udp dport ${port} counter accept comment "Nebula ${domain}"
87 udp sport ${port} counter accept comment "Nebula ${domain}"
90 udp dport ${port} counter accept comment "Nebula ${domain}"
93 udp sport ${port} counter accept comment "Nebula ${domain}"
95 chain input-${iface} {
96 tcp dport ssh counter accept comment "SSH"
97 udp dport 60000-60100 counter accept comment "Mosh"
99 chain output-${iface} {
100 tcp dport ssh counter accept comment "SSH"
101 udp dport 60000-60100 counter accept comment "Mosh"
104 iifname ${iface} jump input-${iface}
105 iifname ${iface} log level warn prefix "input-${iface}: " counter drop
108 oifname ${iface} jump output-${iface}
109 oifname ${iface} log level warn prefix "output-${iface}: " counter drop
113 networking.networkmanager.unmanaged = [ iface ];
114 services.fail2ban.ignoreIP = [
115 "${IPv4Prefix}.1" # mermet.sp
116 "${IPv4Prefix}.2" # losurdo.sp
117 "${IPv4Prefix}.3" # oignon.sp