diff options
author | Robert Hensing <roberth@users.noreply.github.com> | 2022-11-09 13:53:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-09 13:53:57 +0100 |
commit | 93a905ec4fbaf8d13d2debacb07b3ee2c2fc28fa (patch) | |
tree | 0eb62975310020ab6341796c95614278c6efddab /nixos/modules/tasks | |
parent | a8c4cb8835a5f91e9dd92397257452be8e551fe0 (diff) | |
parent | 18e3f431e1b36d4f569ddddd415f95921e1b7748 (diff) |
Merge pull request #194759 from hercules-ci/fqdn-or-hostname
nixos: Add `networking.fqdnOrHostName`
Diffstat (limited to 'nixos/modules/tasks')
-rw-r--r-- | nixos/modules/tasks/network-interfaces.nix | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index 1982175eac94c..b7a4282f9727f 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -473,9 +473,29 @@ in defaultText = literalExpression ''"''${networking.hostName}.''${networking.domain}"''; description = lib.mdDoc '' The fully qualified domain name (FQDN) of this host. It is the result - of combining networking.hostName and networking.domain. Using this + of combining `networking.hostName` and `networking.domain.` Using this option will result in an evaluation error if the hostname is empty or no domain is specified. + + Modules that accept a mere `networing.hostName` but prefer a fully qualified + domain name may use `networking.fqdnOrHostName` instead. + ''; + }; + + networking.fqdnOrHostName = mkOption { + readOnly = true; + type = types.str; + default = if cfg.domain == null then cfg.hostName else cfg.fqdn; + defaultText = literalExpression '' + if cfg.domain == null then cfg.hostName else cfg.fqdn + ''; + description = lib.mdDoc '' + Either the fully qualified domain name (FQDN), or just the host name if + it does not exists. + + This is a convenience option for modules to read instead of `fqdn` when + a mere `hostName` is also an acceptable value; this option does not + throw an error when `domain` is unset. ''; }; |