Browse Source

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

master
Astro 1 month ago
parent
commit
01f3685d9b
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      nix/nixos-module/server/lxc-containers.nix

+ 7
- 1
nix/nixos-module/server/lxc-containers.nix View File

@@ -11,6 +11,12 @@ let
11 11
 
12 12
   enabled = containers != {};
13 13
 
14
+  # linux iface name max length = 15
15
+  shortenNetName = name:
16
+    if builtins.match "priv(.*)" name != null
17
+    then "pr" + builtins.substring 4 9 name
18
+    else name;
19
+
14 20
   # `lxc.net.*` formatter for lxc.container.conf files
15 21
   netConfig = ctName: interfaces:
16 22
     let
@@ -25,7 +31,7 @@ let
25 31
                    then ifData.hwaddr
26 32
                    else "0A:14:48:xx:xx:xx";
27 33
         } // (lib.optionalAttrs (ifData.type == "veth") {
28
-          veth.pair = "${ctName}-${netName}";
34
+          veth.pair = "${ctName}-${shortenNetName netName}";
29 35
           veth.mode = "bridge";
30 36
           link = "${netName}";
31 37
         }) // (lib.optionalAttrs (ifData.type == "phys") {

Loading…
Cancel
Save