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";
51 systemd.services."openvpn-${netns}" = {
55 ${pkgs.curl}/bin/curl -X POST --cacert ${ca} -o ${key-cert} -vLs ${apiUrl}
60 RuntimeDirectory = [ "openvpn-${netns}" ];
61 RuntimeDirectoryMode = "0700";
64 networking.nftables.ruleset = ''
67 skuid root tcp dport https counter accept comment "OpenVPN Calyx"
68 skuid root tcp dport 4430 counter accept comment "OpenVPN Calyx (API)"
72 services.netns.namespaces.${netns} = {
73 nftables = lib.mkBefore ''
74 include "${inputs.julm-nix + "/nixos/profiles/networking/nftables.txt"}"