nixos-module/server/lxc-containers: add shortenNetName
This commit is contained in:
parent
5bda3ab775
commit
01f3685d9b
|
@ -11,6 +11,12 @@ let
|
||||||
|
|
||||||
enabled = containers != {};
|
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
|
# `lxc.net.*` formatter for lxc.container.conf files
|
||||||
netConfig = ctName: interfaces:
|
netConfig = ctName: interfaces:
|
||||||
let
|
let
|
||||||
|
@ -25,7 +31,7 @@ let
|
||||||
then ifData.hwaddr
|
then ifData.hwaddr
|
||||||
else "0A:14:48:xx:xx:xx";
|
else "0A:14:48:xx:xx:xx";
|
||||||
} // (lib.optionalAttrs (ifData.type == "veth") {
|
} // (lib.optionalAttrs (ifData.type == "veth") {
|
||||||
veth.pair = "${ctName}-${netName}";
|
veth.pair = "${ctName}-${shortenNetName netName}";
|
||||||
veth.mode = "bridge";
|
veth.mode = "bridge";
|
||||||
link = "${netName}";
|
link = "${netName}";
|
||||||
}) // (lib.optionalAttrs (ifData.type == "phys") {
|
}) // (lib.optionalAttrs (ifData.type == "phys") {
|
||||||
|
|
Loading…
Reference in New Issue