diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index 2e1514a82cfd..562a945d832a 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -211,14 +211,9 @@ in # it's not configured in the NixOS configuration, since it may # have been set by dhclient in the meantime. system.activationScripts.hostname = - (if config.networking.hostName != "" then '' + optionalString (config.networking.hostName != "") '' hostname "${config.networking.hostName}" - '' else '' - # dhclient won't do anything if the hostname isn't empty. - if test "$(hostname)" = "(none)"; then - hostname "" - fi - ''); + ''; };