1 { config, pkgs, lib, ... }:
5 cfg = config.services.quicktun;
14 services.quicktun = mkOption {
16 description = lib.mdDoc "QuickTun tunnels";
17 type = types.attrsOf (types.submodule {
23 description = lib.mdDoc "";
26 remoteAddress = mkOption {
28 example = "tunnel.example.com";
29 description = lib.mdDoc "";
32 localAddress = mkOption {
35 description = lib.mdDoc "";
38 localPort = mkOption {
41 description = lib.mdDoc "";
44 remotePort = mkOption {
47 description = lib.mdDoc "";
50 remoteFloat = mkOption {
53 description = lib.mdDoc "";
59 description = lib.mdDoc "";
62 privateKey = mkOption {
64 description = lib.mdDoc "";
67 publicKey = mkOption {
69 description = lib.mdDoc "";
72 timeWindow = mkOption {
75 description = lib.mdDoc "";
81 description = lib.mdDoc "";
89 config = mkIf (cfg != []) {
90 systemd.services = foldr (a: b: a // b) {} (
91 mapAttrsToList (name: qtcfg: {
92 "quicktun-${name}" = {
93 wantedBy = [ "multi-user.target" ];
94 after = [ "network.target" ];
97 TUN_MODE = toString qtcfg.tunMode;
98 REMOTE_ADDRESS = qtcfg.remoteAddress;
99 LOCAL_ADDRESS = qtcfg.localAddress;
100 LOCAL_PORT = toString qtcfg.localPort;
101 REMOTE_PORT = toString qtcfg.remotePort;
102 REMOTE_FLOAT = toString qtcfg.remoteFloat;
103 PRIVATE_KEY = qtcfg.privateKey;
104 PUBLIC_KEY = qtcfg.publicKey;
105 TIME_WINDOW = toString qtcfg.timeWindow;
106 TUN_UP_SCRIPT = pkgs.writeScript "quicktun-${name}-up.sh" qtcfg.upScript;
111 ExecStart = "${pkgs.quicktun}/bin/quicktun.${qtcfg.protocol}";