From f43716f28e1c7c787e003bd83dd1e897b360240a Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 6 Oct 2022 16:21:09 +0200 Subject: [PATCH] nixos: Add networking.fqdnOrHostName option, readOnly --- nixos/modules/tasks/network-interfaces.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index 6f01917bcc59..c21675285f64 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -479,6 +479,22 @@ in ''; }; + 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. + ''; + }; + networking.hostId = mkOption { default = null; example = "4e98920d";