From 01f3685d9b7a241c272320b4839c2b6105ca5396 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 6 May 2021 00:50:24 +0200 Subject: [PATCH] nixos-module/server/lxc-containers: add shortenNetName --- nix/nixos-module/server/lxc-containers.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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") {