If container name is already unique, don't append "-0"

When using `--ensure-unique-name`, don't needlessly append `"-0"` if the
container name is already unique.

This is especially helpful with NixOps since when it deploys to a
container it uses `--ensure-unique-name`. This means that the container
name will never match the deployment host due to the `"-0"`. Having the
container name and the host name match isn't exactly a requirement, but
it's nice to have and a small change.

authored by

Peter Jones and committed by
Rok Garbas
5b8c8718 109ba4c8

+1 -1
+1 -1
nixos/modules/virtualisation/nixos-container.pl
··· 97 97 if ($ensureUniqueName) { 98 98 my $base = $containerName; 99 99 for (my $nr = 0; ; $nr++) { 100 - $containerName = "$base-$nr"; 101 100 $confFile = "/etc/containers/$containerName.conf"; 102 101 $root = "/var/lib/containers/$containerName"; 103 102 last unless -e $confFile || -e $root; 103 + $containerName = "$base-$nr"; 104 104 } 105 105 } 106 106