1 { inputs, 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 # WARNING: a change to that CA will likely not be detected
10 # because it being already in the Nix store,
11 # and cause the preStart to fail.
12 hash = "sha256-zLs7TRXrHlPjqdaBN1cmbB062XhKs4cv5ajmrkg4O8s=";
13 curlOptsList = [ "-k" ];
15 key-cert = "/run/openvpn-${netns}/key+cert.pem";
18 services.openvpn.servers.${netns} = {
21 # See: https://gitlab.com/nitrohorse/bitmask-openvpn-generator
23 # new-york (vpn2.calyx.net)
24 [ "162.247.72.193" ] ++
41 remote-cert-tls = "server";
44 tls-cipher = "TLS-DHE-RSA-WITH-AES-128-CBC-SHA";
50 systemd.services."openvpn-${netns}" = {
54 ${pkgs.curl}/bin/curl -X POST --cacert ${ca} -o ${key-cert} -vLs ${apiUrl}
59 StartLimitIntervalSec = 0;
62 RuntimeDirectory = [ "openvpn-${netns}" ];
63 RuntimeDirectoryMode = "0700";
66 networking.nftables.ruleset = ''
69 skuid root tcp dport https counter accept comment "OpenVPN Calyx"
70 skuid root tcp dport 4430 counter accept comment "OpenVPN Calyx (API)"
74 services.netns.namespaces.${netns} = {
75 nftables = lib.mkBefore ''
76 include "${inputs.julm-nix + "/nixos/profiles/networking/nftables.txt"}"