mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 12:15:34 +03:00
nixos/networking-interfaces: set default value for virtualType
This commit is contained in:
parent
dc52fc6dda
commit
46c158a32f
3 changed files with 17 additions and 21 deletions
|
@ -230,9 +230,7 @@ let
|
|||
RemainAfterExit = true;
|
||||
};
|
||||
script = ''
|
||||
ip tuntap add dev "${i.name}" \
|
||||
${optionalString (i.virtualType != null) "mode ${i.virtualType}"} \
|
||||
user "${i.virtualOwner}"
|
||||
ip tuntap add dev "${i.name}" mode "${i.virtualType}" user "${i.virtualOwner}"
|
||||
'';
|
||||
postStop = ''
|
||||
ip link del ${i.name} || true
|
||||
|
|
|
@ -74,21 +74,17 @@ in
|
|||
networks."99-main" = genericNetwork mkDefault;
|
||||
}
|
||||
(mkMerge (flip map interfaces (i: {
|
||||
netdevs = mkIf i.virtual (
|
||||
let
|
||||
devType = if i.virtualType != null then i.virtualType
|
||||
else (if hasPrefix "tun" i.name then "tun" else "tap");
|
||||
in {
|
||||
"40-${i.name}" = {
|
||||
netdevConfig = {
|
||||
Name = i.name;
|
||||
Kind = devType;
|
||||
};
|
||||
"${devType}Config" = optionalAttrs (i.virtualOwner != null) {
|
||||
User = i.virtualOwner;
|
||||
};
|
||||
netdevs = mkIf i.virtual ({
|
||||
"40-${i.name}" = {
|
||||
netdevConfig = {
|
||||
Name = i.name;
|
||||
Kind = i.virtualType;
|
||||
};
|
||||
});
|
||||
"${i.virtualType}Config" = optionalAttrs (i.virtualOwner != null) {
|
||||
User = i.virtualOwner;
|
||||
};
|
||||
};
|
||||
});
|
||||
networks."40-${i.name}" = mkMerge [ (genericNetwork mkDefault) {
|
||||
name = mkDefault i.name;
|
||||
DHCP = mkForce (dhcpStr
|
||||
|
|
|
@ -273,11 +273,13 @@ let
|
|||
};
|
||||
|
||||
virtualType = mkOption {
|
||||
default = null;
|
||||
type = with types; nullOr (enum [ "tun" "tap" ]);
|
||||
default = if hasPrefix "tun" name then "tun" else "tap";
|
||||
defaultText = ''if hasPrefix "tun" name then "tun" else "tap"'';
|
||||
type = with types; enum [ "tun" "tap" ];
|
||||
description = ''
|
||||
The explicit type of interface to create. Accepts tun or tap strings.
|
||||
Also accepts null to implicitly detect the type of device.
|
||||
The type of interface to create.
|
||||
The default is TUN for an interface name starting
|
||||
with "tun", otherwise TAP.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue