summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Weiss <dev.primeos@gmail.com>2020-06-03 15:12:21 +0200
committerMichael Weiss <dev.primeos@gmail.com>2020-06-03 15:23:37 +0200
commita6afdbb70bad2c8c400de8288155f8cb325cadd6 (patch)
tree31076ed99238add93e56ed6f876cc7a297ae9e05
parent86a8c3f48591257f2fe4f25dddcc5958f287ebd4 (diff)
downloadnixpkgs-a6afdbb70bad2c8c400de8288155f8cb325cadd6.tar
nixpkgs-a6afdbb70bad2c8c400de8288155f8cb325cadd6.tar.gz
nixpkgs-a6afdbb70bad2c8c400de8288155f8cb325cadd6.tar.bz2
nixpkgs-a6afdbb70bad2c8c400de8288155f8cb325cadd6.tar.lz
nixpkgs-a6afdbb70bad2c8c400de8288155f8cb325cadd6.tar.xz
nixpkgs-a6afdbb70bad2c8c400de8288155f8cb325cadd6.tar.zst
nixpkgs-a6afdbb70bad2c8c400de8288155f8cb325cadd6.zip
nixos: Allow empty hostnames again
This fixes a regression from 993baa587c4 which requires
networking.hostName to be a valid DNS label [0].
Unfortunately we missed the fact that the hostnames may also be empty,
if the user wants to obtain it from a DHCP server. This is even required
by a few modules/images (e.g. Amazon EC2, Azure, and Google Compute).

[0]: https://github.com/NixOS/nixpkgs/pull/76542#issuecomment-638138666
-rw-r--r--nixos/modules/tasks/network-interfaces.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix
index a2811104944..78d66966949 100644
--- a/nixos/modules/tasks/network-interfaces.nix
+++ b/nixos/modules/tasks/network-interfaces.nix
@@ -381,7 +381,7 @@ in
       # syntax). Note: We also allow underscores for compatibility/legacy
       # reasons (as undocumented feature):
       type = types.strMatching
-        "^[[:alpha:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$";
+        "^$|^[[:alpha:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$";
       description = ''
         The name of the machine. Leave it empty if you want to obtain it from a
         DHCP server (if using DHCP). The hostname must be a valid DNS label (see