aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/openvpn.nix
blob: 57d59ee354d67608e5df31881a0d7e759bd916bd (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
45
{
  config,
  lib,
  pkgs,
  ...
}: 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;
      };
    };
  };
}