From 77c49d933380126bdc25948807a94ac5b50be577 Mon Sep 17 00:00:00 2001 From: Boris Sukholitko Date: Sat, 22 Aug 2015 13:01:09 +0300 Subject: [PATCH] containers: add interfaces config option. It uses systemd-nspawn's --network-interface to move existing interfaces into the container. --- nixos/modules/virtualisation/containers.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix index da39dda85353..d819d99e09ca 100644 --- a/nixos/modules/virtualisation/containers.nix +++ b/nixos/modules/virtualisation/containers.nix @@ -120,6 +120,15 @@ in ''; }; + interfaces = mkOption { + type = types.listOf types.string; + default = null; + example = [ "eth1" "eth2" ]; + description = '' + The list of interfaces to be moved into the container. + ''; + }; + autoStart = mkOption { type = types.bool; default = false; @@ -218,6 +227,10 @@ in extraFlags+=" --network-veth" fi + for iface in $INTERFACES; do + extraFlags+=" --network-interface=$iface" + done + for iface in $MACVLANS; do extraFlags+=" --network-macvlan=$iface" done @@ -331,6 +344,9 @@ in LOCAL_ADDRESS=${cfg.localAddress} ''} ''} + ${optionalString (cfg.interfaces != null) '' + INTERFACES="${toString cfg.interfaces}" + ''} ${optionalString cfg.autoStart '' AUTO_START=1 ''}