diff options
author | Boris Sukholitko <boriss@gmail.com> | 2015-08-22 13:01:09 +0300 |
---|---|---|
committer | Boris Sukholitko <boriss@gmail.com> | 2015-08-22 13:03:07 +0300 |
commit | 77c49d933380126bdc25948807a94ac5b50be577 (patch) | |
tree | 997563e6dae609c2e5938581c7e16dab85bc62f3 /nixos/modules | |
parent | a1d85fc261027bcae8e403115d21cd31a2b4dbb5 (diff) | |
download | nixlib-77c49d933380126bdc25948807a94ac5b50be577.tar nixlib-77c49d933380126bdc25948807a94ac5b50be577.tar.gz nixlib-77c49d933380126bdc25948807a94ac5b50be577.tar.bz2 nixlib-77c49d933380126bdc25948807a94ac5b50be577.tar.lz nixlib-77c49d933380126bdc25948807a94ac5b50be577.tar.xz nixlib-77c49d933380126bdc25948807a94ac5b50be577.tar.zst nixlib-77c49d933380126bdc25948807a94ac5b50be577.zip |
containers: add interfaces config option.
It uses systemd-nspawn's --network-interface to move existing interfaces into the container.
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/virtualisation/containers.nix | 16 |
1 files changed, 16 insertions, 0 deletions
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 ''} |