diff options
author | Ian-Woo Kim <ianwookim@gmail.com> | 2015-09-28 06:02:52 +0000 |
---|---|---|
committer | Ian-Woo Kim <ianwookim@gmail.com> | 2015-09-28 06:02:52 +0000 |
commit | b3eebcd93c27039e1800dece22e40f18ce4c582b (patch) | |
tree | 530da5a58da905c0598737aa252c9029743d61fe /nixos/modules/virtualisation/containers.nix | |
parent | c6b031d32bae47f497050f5586ecd3f5ed3740b6 (diff) | |
parent | e8ebf051a9ecd812df563fd45bdf607e882da814 (diff) | |
download | nixlib-b3eebcd93c27039e1800dece22e40f18ce4c582b.tar nixlib-b3eebcd93c27039e1800dece22e40f18ce4c582b.tar.gz nixlib-b3eebcd93c27039e1800dece22e40f18ce4c582b.tar.bz2 nixlib-b3eebcd93c27039e1800dece22e40f18ce4c582b.tar.lz nixlib-b3eebcd93c27039e1800dece22e40f18ce4c582b.tar.xz nixlib-b3eebcd93c27039e1800dece22e40f18ce4c582b.tar.zst nixlib-b3eebcd93c27039e1800dece22e40f18ce4c582b.zip |
Merge branch 'master' into extra-binds
Diffstat (limited to 'nixos/modules/virtualisation/containers.nix')
-rw-r--r-- | nixos/modules/virtualisation/containers.nix | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix index 6012499b0683..121ecbc9bf2c 100644 --- a/nixos/modules/virtualisation/containers.nix +++ b/nixos/modules/virtualisation/containers.nix @@ -12,6 +12,12 @@ let perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/lib/perl5/site_perl"; su = "${pkgs.shadow.su}/bin/su"; inherit (pkgs) utillinux; + + postInstall = '' + t=$out/etc/bash_completion.d + mkdir -p $t + cp ${./nixos-container-completion.sh} $t/nixos-container + ''; }; # The container's init script, a small wrapper around the regular @@ -137,7 +143,7 @@ in }; hostAddress = mkOption { - type = types.nullOr types.string; + type = types.nullOr types.str; default = null; example = "10.231.136.1"; description = '' @@ -146,7 +152,7 @@ in }; localAddress = mkOption { - type = types.nullOr types.string; + type = types.nullOr types.str; default = null; example = "10.231.136.2"; description = '' @@ -155,6 +161,15 @@ in ''; }; + interfaces = mkOption { + type = types.listOf types.string; + default = []; + example = [ "eth1" "eth2" ]; + description = '' + The list of interfaces to be moved into the container. + ''; + }; + autoStart = mkOption { type = types.bool; default = false; @@ -268,6 +283,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 @@ -339,7 +358,7 @@ in '' #! ${pkgs.stdenv.shell} -e ${nixos-container}/bin/nixos-container run "$INSTANCE" -- \ - bash --login -c "/nix/var/nix/profiles/system/bin/switch-to-configuration test" + bash --login -c "''${SYSTEM_PATH:-/nix/var/nix/profiles/system}/bin/switch-to-configuration test" ''; SyslogIdentifier = "container %i"; @@ -384,10 +403,11 @@ in LOCAL_ADDRESS=${cfg.localAddress} ''} ''} - ${optionalString cfg.autoStart '' - AUTO_START=1 - ''} - EXTRA_NSPAWN_FLAGS="${mkBindFlags cfg.bindMounts}" + INTERFACES="${toString cfg.interfaces}" + ${optionalString cfg.autoStart '' + AUTO_START=1 + ''} + EXTRA_NSPAWN_FLAGS="${mkBindFlags cfg.bindMounts}" ''; }) config.containers; |