mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 12:53:59 +03:00
containers: add interfaces config option.
It uses systemd-nspawn's --network-interface to move existing interfaces into the container.
This commit is contained in:
parent
a1d85fc261
commit
77c49d9333
@ -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 {
|
autoStart = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
@ -218,6 +227,10 @@ in
|
|||||||
extraFlags+=" --network-veth"
|
extraFlags+=" --network-veth"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for iface in $INTERFACES; do
|
||||||
|
extraFlags+=" --network-interface=$iface"
|
||||||
|
done
|
||||||
|
|
||||||
for iface in $MACVLANS; do
|
for iface in $MACVLANS; do
|
||||||
extraFlags+=" --network-macvlan=$iface"
|
extraFlags+=" --network-macvlan=$iface"
|
||||||
done
|
done
|
||||||
@ -331,6 +344,9 @@ in
|
|||||||
LOCAL_ADDRESS=${cfg.localAddress}
|
LOCAL_ADDRESS=${cfg.localAddress}
|
||||||
''}
|
''}
|
||||||
''}
|
''}
|
||||||
|
${optionalString (cfg.interfaces != null) ''
|
||||||
|
INTERFACES="${toString cfg.interfaces}"
|
||||||
|
''}
|
||||||
${optionalString cfg.autoStart ''
|
${optionalString cfg.autoStart ''
|
||||||
AUTO_START=1
|
AUTO_START=1
|
||||||
''}
|
''}
|
||||||
|
Loading…
Reference in New Issue
Block a user