diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix index 7d445fa0951e..7193029d4518 100644 --- a/nixos/modules/virtualisation/containers.nix +++ b/nixos/modules/virtualisation/containers.nix @@ -89,6 +89,9 @@ let if [ -n "$HOST_BRIDGE" ]; then extraFlags+=" --network-bridge=$HOST_BRIDGE" fi + if [ -n "$HOST_PORT" ]; then + extraFlags+=" --port=$HOST_PORT" + fi fi extraFlags+=" ${concatStringsSep " " (mapAttrsToList nspawnExtraVethArgs cfg.extraVeths)}" diff --git a/pkgs/tools/virtualization/nixos-container/nixos-container.pl b/pkgs/tools/virtualization/nixos-container/nixos-container.pl index 18ee2f111b41..cde79f8a8208 100755 --- a/pkgs/tools/virtualization/nixos-container/nixos-container.pl +++ b/pkgs/tools/virtualization/nixos-container/nixos-container.pl @@ -16,7 +16,7 @@ umask 0022; sub showHelp { print < [--nixos-path ] [--system-path ] [--config-file ] [--config ] [--ensure-unique-name] [--auto-start] [--bridge ] + nixos-container create [--nixos-path ] [--system-path ] [--config-file ] [--config ] [--ensure-unique-name] [--auto-start] [--bridge ] [--port ] nixos-container destroy nixos-container start nixos-container stop @@ -37,6 +37,7 @@ my $nixosPath; my $ensureUniqueName = 0; my $autoStart = 0; my $bridge; +my $port; my $extraConfig; my $signal; my $configFile; @@ -46,6 +47,7 @@ GetOptions( "ensure-unique-name" => \$ensureUniqueName, "auto-start" => \$autoStart, "bridge=s" => \$bridge, + "port=s" => \$port, "system-path=s" => \$systemPath, "signal=s" => \$signal, "nixos-path=s" => \$nixosPath, @@ -156,6 +158,7 @@ if ($action eq "create") { push @conf, "HOST_ADDRESS=$hostAddress\n"; push @conf, "LOCAL_ADDRESS=$localAddress\n"; push @conf, "HOST_BRIDGE=$bridge\n"; + push @conf, "HOST_PORT=$port\n"; push @conf, "AUTO_START=$autoStart\n"; write_file($confFile, \@conf);