Allow forwarding of multiple ports
This commit is contained in:
21
flake.nix
21
flake.nix
@@ -48,12 +48,16 @@
|
||||
type = bool;
|
||||
default = true;
|
||||
};
|
||||
proto = mkOption {type = proto;};
|
||||
dest = mkOption {type = str;};
|
||||
hostProto = mkOption {type = proto;};
|
||||
port = mkOption {type = port;};
|
||||
forwards = mkOption {
|
||||
type = listOf (submodule {
|
||||
options = {
|
||||
proto = mkOption {type = proto;};
|
||||
port = mkOption {type = port;};
|
||||
dest = mkOption {type = str;};
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
config.hostProto = mkDefault config.proto;
|
||||
}));
|
||||
};
|
||||
};
|
||||
@@ -65,10 +69,7 @@
|
||||
};
|
||||
in
|
||||
lib.mapAttrs' (hostname: {
|
||||
proto,
|
||||
hostProto,
|
||||
port,
|
||||
dest,
|
||||
forwards,
|
||||
enable,
|
||||
...
|
||||
}: let
|
||||
@@ -78,7 +79,7 @@
|
||||
value = {
|
||||
inherit enable;
|
||||
script = ''
|
||||
TS_AUTHKEY=$(cat $RUNTIME_DIRECTORY/authkey) ${lib.getExe self.packages.${pkgs.system}.default} ${hostProto} ${hostname} ${toString port} ${proto} ${dest}
|
||||
TS_AUTHKEY=$(cat $RUNTIME_DIRECTORY/authkey) ${lib.getExe self.packages.${pkgs.system}.default} ${hostname} ${lib.concatMapStringsSep " " ({proto, port, dest}: "${proto}:${toString port}:${dest}") forwards}
|
||||
'';
|
||||
wantedBy = ["multi-user.target"];
|
||||
serviceConfig = {
|
||||
|
||||
Reference in New Issue
Block a user