1 { pkgs, lib, config, ... }:
4 inherit (config.services) openvpn;
5 apiUrl = "https://api.calyx.net:4430/3/cert";
8 url = "https://calyx.net/ca.crt";
9 hash = "sha256-zLs7TRXrHlPjqdaBN1cmbB062XhKs4cv5ajmrkg4O8s=";
10 curlOptsList = [ "-k" ];
12 key-cert = "/run/openvpn-${netns}/key+cert.pem";
15 services.openvpn.servers.${netns} = {
19 # new-york (vpn2.calyx.net)
20 [ "162.247.72.193" ] ++
37 remote-cert-tls = "server";
40 tls-cipher = "TLS-DHE-RSA-WITH-AES-128-CBC-SHA";
47 systemd.services."openvpn-${netns}" = {
48 after = [ "network-online.target" ];
52 ${pkgs.curl}/bin/curl -X POST --cacert ${ca} -o ${key-cert} -vLs ${apiUrl}
57 RuntimeDirectory = [ "openvpn-${netns}" ];
58 RuntimeDirectoryMode = "0700";
61 networking.nftables.ruleset = ''
64 skuid root tcp dport https counter accept comment "OpenVPN Calyx"
65 skuid root tcp dport 4430 counter accept comment "OpenVPN Calyx (API)"
69 services.netns.namespaces.${netns} = {
70 nftables = lib.mkBefore ''
71 include "${../networking/nftables.txt}"
74 meta l4proto { udp, tcp } th dport domain counter accept comment "DNS"
75 log prefix "calyx: output-lan: " counter drop
78 tcp dport { http, https } counter accept comment "HTTP"
79 log prefix "calyx: output-net: " counter drop
82 ip daddr 10.0.0.0/8 counter goto output-lan
83 ip daddr 172.16.0.0/12 counter goto output-lan
84 ip daddr 192.168.0.0/16 counter goto output-lan
85 ip daddr 224.0.0.0/3 counter goto output-lan
87 log prefix "calyx: output: " counter drop