aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/openvpn.nix
blob: d80dd9dbe9336c807506b0ea8ac00d4d83f96b55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{
  config,
  lib,
  ...
}: let
  inherit (lib) mkOption types mkIf;
  cnf = config.cynerd.openvpn;
in {
  options = {
    cynerd.openvpn = {
      personal = mkOption {
        type = types.bool;
        default = false;
        description = "My personal OpenVPN";
      };
      oldpersonal = mkOption {
        type = types.bool;
        default = false;
        description = "My personal old OpenVPN";
      };
      elektroline = mkOption {
        type = types.bool;
        default = false;
        description = "Elektroline OpenVPN";
      };
    };
  };

  config = {
    services.openvpn.servers = {
      personal = mkIf cnf.personal {
        config = "config /run/secrets/personal.ovpn";
      };
      oldpersonal = mkIf cnf.oldpersonal {
        config = "config /run/secrets/old.ovpn";
      };
      elektroline = mkIf cnf.elektroline {
        autoStart = false;
        config = "config /run/secrets/elektroline.ovpn";
        updateResolvConf = true;
      };
    };
  };
}