nixos-container: support multiple port forwarding. change type of hostPort from 'string' to 'listOf str'
This commit is contained in:
parent
8684285251
commit
0bfc631de2
@ -90,7 +90,13 @@ let
|
|||||||
extraFlags+=" --network-bridge=$HOST_BRIDGE"
|
extraFlags+=" --network-bridge=$HOST_BRIDGE"
|
||||||
fi
|
fi
|
||||||
if [ -n "$HOST_PORT" ]; then
|
if [ -n "$HOST_PORT" ]; then
|
||||||
extraFlags+=" --port=$HOST_PORT"
|
OIFS=$IFS
|
||||||
|
IFS=","
|
||||||
|
for i in $HOST_PORT
|
||||||
|
do
|
||||||
|
extraFlags+=" --port=$i"
|
||||||
|
done
|
||||||
|
IFS=$OIFS
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -320,11 +326,11 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
hostPort = mkOption {
|
hostPort = mkOption {
|
||||||
type = types.nullOr types.string;
|
type = types.listOf types.str;
|
||||||
default = null;
|
default = null;
|
||||||
example = "8080";
|
example = [ "8080" ];
|
||||||
description = ''
|
description = ''
|
||||||
Allow port forwarding from the host to the container.
|
List of forwarded ports from the host to the container.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -665,8 +671,8 @@ in
|
|||||||
${optionalString (cfg.hostBridge != null) ''
|
${optionalString (cfg.hostBridge != null) ''
|
||||||
HOST_BRIDGE=${cfg.hostBridge}
|
HOST_BRIDGE=${cfg.hostBridge}
|
||||||
''}
|
''}
|
||||||
${optionalString (cfg.hostPort != null) ''
|
${optionalString (length cfg.hostPort > 0) ''
|
||||||
HOST_PORT=${cfg.hostPort}
|
HOST_PORT=${concatStringsSep "," cfg.hostPort}
|
||||||
''}
|
''}
|
||||||
${optionalString (cfg.hostAddress != null) ''
|
${optionalString (cfg.hostAddress != null) ''
|
||||||
HOST_ADDRESS=${cfg.hostAddress}
|
HOST_ADDRESS=${cfg.hostAddress}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user