diff --git a/nix/nixos-module/server/lxc-containers.nix b/nix/nixos-module/server/lxc-containers.nix index 145981f..cc2cbff 100644 --- a/nix/nixos-module/server/lxc-containers.nix +++ b/nix/nixos-module/server/lxc-containers.nix @@ -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") {