nixos-module/server/lxc-containers: add shortenNetName

Этот коммит содержится в:
Astro 2021-05-06 00:50:24 +02:00
родитель 5bda3ab775
Коммит 01f3685d9b
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -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") {