nixos/networking: allow users to override FQDN

This may be useful for users where `${cfg.hostname}.${cfg.domain}` isn't
actually the fully quantified domain name of the server.
This commit is contained in:
Michael Hoang 2025-03-20 18:29:19 +09:00
parent 2631b0b7ab
commit 4d537721f7

View file

@ -578,21 +578,22 @@ in
}; };
networking.fqdn = mkOption { networking.fqdn = mkOption {
readOnly = true;
type = types.str; type = types.str;
default = default =
if (cfg.hostName != "" && cfg.domain != null) then if (cfg.hostName != "" && cfg.domain != null) then
"${cfg.hostName}.${cfg.domain}" "${cfg.hostName}.${cfg.domain}"
else else
throw '' throw ''
The FQDN is required but cannot be determined. Please make sure that The FQDN is required but cannot be determined from `networking.hostName`
both networking.hostName and networking.domain are set properly. and `networking.domain`. Please ensure these options are set properly or
set `networking.fqdn` directly.
''; '';
defaultText = literalExpression ''"''${networking.hostName}.''${networking.domain}"''; defaultText = literalExpression ''"''${networking.hostName}.''${networking.domain}"'';
description = '' description = ''
The fully qualified domain name (FQDN) of this host. It is the result The fully qualified domain name (FQDN) of this host. By default, it is
of combining `networking.hostName` and `networking.domain.` Using this the result of combining `networking.hostName` and `networking.domain.`
option will result in an evaluation error if the hostname is empty or
Using this option will result in an evaluation error if the hostname is empty or
no domain is specified. no domain is specified.
Modules that accept a mere `networking.hostName` but prefer a fully qualified Modules that accept a mere `networking.hostName` but prefer a fully qualified