mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-11 17:39:37 +08:00
programs/ssh: DRY address/port options
The end goal is to hoist the forwarded path assertion directly into this module rather than the top-level.
This commit is contained in:
committed by
Austin Horstman
parent
4067ca1ffb
commit
bec08ef6e3
@@ -30,44 +30,42 @@ let
|
||||
mapAttrsToList (name: value: ''${name}="${lib.escape [ ''"'' "\\" ] (toString value)}"'') envStr
|
||||
);
|
||||
|
||||
bindOptions = {
|
||||
address = mkOption {
|
||||
type = types.str;
|
||||
default = "localhost";
|
||||
example = "example.org";
|
||||
description = "The address where to bind the port.";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.nullOr types.port;
|
||||
default = null;
|
||||
example = 8080;
|
||||
description = "Specifies port number to bind on bind address.";
|
||||
};
|
||||
};
|
||||
|
||||
dynamicForwardModule = types.submodule { options = bindOptions; };
|
||||
|
||||
forwardModule = types.submodule {
|
||||
options = {
|
||||
bind = bindOptions;
|
||||
|
||||
host = {
|
||||
mkAddressPortModule =
|
||||
{
|
||||
actionType,
|
||||
nullableAddress ? actionType == "forward",
|
||||
}:
|
||||
types.submodule {
|
||||
options = {
|
||||
address = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
type = if nullableAddress then types.nullOr types.str else types.str;
|
||||
default = if nullableAddress then null else "localhost";
|
||||
example = "example.org";
|
||||
description = "The address where to forward the traffic to.";
|
||||
description = "The address to ${actionType} to.";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.nullOr types.port;
|
||||
default = null;
|
||||
example = 80;
|
||||
description = "Specifies port number to forward the traffic to.";
|
||||
example = 8080;
|
||||
description = "Specifies port number to ${actionType} to.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
dynamicForwardModule = mkAddressPortModule { actionType = "bind"; };
|
||||
|
||||
forwardModule = types.submodule {
|
||||
options = {
|
||||
bind = mkOption {
|
||||
type = mkAddressPortModule { actionType = "bind"; };
|
||||
description = "Local port binding options";
|
||||
};
|
||||
host = mkOption {
|
||||
type = mkAddressPortModule { actionType = "forward"; };
|
||||
description = "Host port binding options";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
matchBlockModule = types.submodule {
|
||||
|
||||
Reference in New Issue
Block a user