{ pkgs, lib, config, inputs, hostName, ... }: let domain = "sourcephile.fr"; port = toString config.services.nebula.networks.${domain}.listen.port; iface = config.services.nebula.networks.${domain}.tun.device; in { environment.systemPackages = with pkgs; [ nebula ]; systemd.services."nebula@${domain}".serviceConfig.LoadCredentialEncrypted = [ "${hostName}.key:${inputs.self + "/hosts/${hostName}/nebula/${hostName}.key.cred"}" ]; install.target = lib.mkDefault "\"\${NIXOS_TARGET:-root@${config.networking.hostName}.sp}\""; networking.hosts = { "10.0.0.1" = [ "mermet.sp" ]; "10.0.0.2" = [ "losurdo.sp" ]; "10.0.0.3" = [ "oignon.sp" ]; "10.0.0.4" = [ "patate.sp" ]; "10.0.0.5" = [ "carotte.sp" ]; "10.0.0.6" = [ "aubergine.sp" ]; "10.0.0.7" = [ "courge.sp" ]; }; services.nebula.networks.${domain} = { enable = true; ca = lib.mkDefault (./. + "/${domain}/ca.crt"); cert = lib.mkDefault (inputs.self + "/share/nebula/${domain}/${hostName}.crt"); key = "/run/credentials/nebula@${domain}.service/${hostName}.key"; listen.host = lib.mkDefault "0.0.0.0"; tun.device = lib.mkDefault "neb-sourcephile"; staticHostMap = { "10.0.0.1" = [ "mermet.${domain}:10001" ]; "10.0.0.2" = [ "losurdo.${domain}:10002" ]; }; lighthouses = [ "10.0.0.1" "10.0.0.2" ]; relays = [ "10.0.0.1" ]; firewall = { inbound = [ { port = "any"; proto = "icmp"; groups = [ "sourcephile" "intra" ]; } ]; outbound = [ { port = "any"; proto = "icmp"; groups = [ "sourcephile" "intra" ]; } ]; }; settings = { firewall = { conntrack = { tcp_timeout = "12m"; udp_timeout = "3m"; default_timeout = "10m"; }; }; logging = { level = lib.mkDefault "info"; }; pki.disconnect_invalid = true; preferred_ranges = [ "192.168.0.0/16" ]; /* stats = { type = "prometheus"; listen = "127.0.0.1:8080"; path = "/metrics"; namespace = "prometheusns"; subsystem = "nebula"; interval = "10s"; message_metrics = false; lighthouse_metrics = false; }; */ }; }; networking.nftables.ruleset = '' table inet filter { chain input-lan { udp dport ${port} counter accept comment "Nebula ${domain}" } chain output-lan { udp sport ${port} counter accept comment "Nebula ${domain}" } chain input-net { udp dport ${port} counter accept comment "Nebula ${domain}" } chain output-net { udp sport ${port} counter accept comment "Nebula ${domain}" } chain input-${iface} { tcp dport ssh counter accept comment "SSH" udp dport 60000-60100 counter accept comment "Mosh" } chain output-${iface} { tcp dport ssh counter accept comment "SSH" udp dport 60000-60100 counter accept comment "Mosh" } chain input { iifname ${iface} jump input-${iface} iifname ${iface} log level warn prefix "input-${iface}: " counter drop } chain output { oifname ${iface} jump output-${iface} oifname ${iface} log level warn prefix "output-${iface}: " counter drop } } ''; networking.networkmanager.unmanaged = [ iface ]; }