nixos-module/server/lxc-containers: add shortenNetName
This commit is contained in:
parent
5bda3ab775
commit
01f3685d9b
|
@ -11,6 +11,12 @@ let
|
|||
|
||||
enabled = containers != {};
|
||||
|
||||
# linux iface name max length = 15
|
||||
shortenNetName = name:
|
||||
if builtins.match "priv(.*)" name != null
|
||||
then "pr" + builtins.substring 4 9 name
|
||||
else name;
|
||||
|
||||
# `lxc.net.*` formatter for lxc.container.conf files
|
||||
netConfig = ctName: interfaces:
|
||||
let
|
||||
|
@ -25,7 +31,7 @@ let
|
|||
then ifData.hwaddr
|
||||
else "0A:14:48:xx:xx:xx";
|
||||
} // (lib.optionalAttrs (ifData.type == "veth") {
|
||||
veth.pair = "${ctName}-${netName}";
|
||||
veth.pair = "${ctName}-${shortenNetName netName}";
|
||||
veth.mode = "bridge";
|
||||
link = "${netName}";
|
||||
}) // (lib.optionalAttrs (ifData.type == "phys") {
|
||||
|
|
Loading…
Reference in New Issue