networking: set targetHost if FQDN is explicitly set

This commit is contained in:
Michael Hoang
2025-04-23 00:14:36 +10:00
parent 74e64d413f
commit e6e7f5d5de

View File

@@ -1,5 +1,6 @@
{ {
_class, _class,
options,
config, config,
lib, lib,
... ...
@@ -24,7 +25,15 @@
- root@example.com:2222?IdentityFile=/path/to/private/key&StrictHostKeyChecking=yes - root@example.com:2222?IdentityFile=/path/to/private/key&StrictHostKeyChecking=yes
''; '';
default = default =
if config.networking.domain != null then "root@${config.networking.fqdnOrHostName}" else null; if
(
config.networking.domain != null
|| options.networking.fqdn.highestPrio < (lib.mkOptionDefault { }).priority
)
then
"root@${config.networking.fqdn}"
else
null;
defaultText = lib.literalExpression ''if config.networking.domain is not null then "root@''${config.networking.fqdnOrHostName}" else null''; defaultText = lib.literalExpression ''if config.networking.domain is not null then "root@''${config.networking.fqdnOrHostName}" else null'';
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
}; };