summary refs log tree commit diff
path: root/nixos/modules/virtualisation/containers.nix
diff options
context:
space:
mode:
authorIan-Woo Kim <ianwookim@gmail.com>2016-12-04 04:00:07 +0000
committerRobin Gloster <mail@glob.in>2017-02-15 05:12:46 +0100
commit0bfc631de20a351b23af571e80347df1a58a298a (patch)
treebb9209506f449f47124dff7d219b23b156ec15b2 /nixos/modules/virtualisation/containers.nix
parent86842852513a8e0132e5580802b0fa1d90ef5f9b (diff)
downloadnixpkgs-0bfc631de20a351b23af571e80347df1a58a298a.tar
nixpkgs-0bfc631de20a351b23af571e80347df1a58a298a.tar.gz
nixpkgs-0bfc631de20a351b23af571e80347df1a58a298a.tar.bz2
nixpkgs-0bfc631de20a351b23af571e80347df1a58a298a.tar.lz
nixpkgs-0bfc631de20a351b23af571e80347df1a58a298a.tar.xz
nixpkgs-0bfc631de20a351b23af571e80347df1a58a298a.tar.zst
nixpkgs-0bfc631de20a351b23af571e80347df1a58a298a.zip
nixos-container: support multiple port forwarding. change type of hostPort from 'string' to 'listOf str'
Diffstat (limited to 'nixos/modules/virtualisation/containers.nix')
-rw-r--r--nixos/modules/virtualisation/containers.nix18
1 files changed, 12 insertions, 6 deletions
diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix
index 88273545c2b..83b7a2fdecd 100644
--- a/nixos/modules/virtualisation/containers.nix
+++ b/nixos/modules/virtualisation/containers.nix
@@ -90,7 +90,13 @@ let
           extraFlags+=" --network-bridge=$HOST_BRIDGE"
         fi
         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
 
@@ -320,11 +326,11 @@ let
     };
 
     hostPort = mkOption {
-      type = types.nullOr types.string;
+      type = types.listOf types.str;
       default = null;
-      example = "8080";
+      example = [ "8080" ];
       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) ''
                 HOST_BRIDGE=${cfg.hostBridge}
               ''}
-              ${optionalString (cfg.hostPort != null) ''
-                HOST_PORT=${cfg.hostPort}
+              ${optionalString (length cfg.hostPort > 0) ''
+                HOST_PORT=${concatStringsSep "," cfg.hostPort}
               ''}
               ${optionalString (cfg.hostAddress != null) ''
                 HOST_ADDRESS=${cfg.hostAddress}