diff options
author | Arian van Putten <aeroboy94@gmail.com> | 2018-12-02 15:24:17 +0100 |
---|---|---|
committer | Arian van Putten <aeroboy94@gmail.com> | 2018-12-02 15:26:39 +0100 |
commit | bf102825efa1deb8de1afca4ed7541c098f6b068 (patch) | |
tree | 6db3421de61d740ff1320909bbbcc0394e862f2d /nixos/modules/virtualisation | |
parent | 7035598251f7e1393b2b1cd6aa01c32aa1fa6343 (diff) | |
download | nixlib-bf102825efa1deb8de1afca4ed7541c098f6b068.tar nixlib-bf102825efa1deb8de1afca4ed7541c098f6b068.tar.gz nixlib-bf102825efa1deb8de1afca4ed7541c098f6b068.tar.bz2 nixlib-bf102825efa1deb8de1afca4ed7541c098f6b068.tar.lz nixlib-bf102825efa1deb8de1afca4ed7541c098f6b068.tar.xz nixlib-bf102825efa1deb8de1afca4ed7541c098f6b068.tar.zst nixlib-bf102825efa1deb8de1afca4ed7541c098f6b068.zip |
nixos/containers: Add assertion for container name length
When privateNetwork is enabled, currently the container's interface name is derived from the container name. However, there's a hard limit on the size of interface names. To avoid conflicts and other issues, we set a limit on the container name when privateNetwork is enabled. Fixes #38509
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r-- | nixos/modules/virtualisation/containers.nix | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix index 2fcc0f254256..fba69f7b42ba 100644 --- a/nixos/modules/virtualisation/containers.nix +++ b/nixos/modules/virtualisation/containers.nix @@ -457,6 +457,16 @@ in { boot.isContainer = true; networking.hostName = mkDefault name; networking.useDHCP = false; + assertions = [ + { + assertion = config.privateNetwork -> stringLength name < 12; + message = '' + Container name `${name}` is too long: When `privateNetwork` is enabled, container names can + not be longer than 11 characters, because the container's interface name is derived from it. + This might be fixed in the future. See https://github.com/NixOS/nixpkgs/issues/38509 + ''; + } + ]; }; in [ extraConfig ] ++ (map (x: x.value) defs); prefix = [ "containers" name ]; |