Merge pull request #194759 from hercules-ci/fqdn-or-hostname

nixos: Add `networking.fqdnOrHostName`

authored by Robert Hensing and committed by GitHub 93a905ec a8c4cb88

+36 -33
+3 -4
nixos/modules/services/cluster/kubernetes/kubelet.nix
··· 177 177 178 178 hostname = mkOption { 179 179 description = lib.mdDoc "Kubernetes kubelet hostname override."; 180 - default = config.networking.hostName; 181 - defaultText = literalExpression "config.networking.hostName"; 180 + defaultText = literalExpression "config.networking.fqdnOrHostName"; 182 181 type = str; 183 182 }; 184 183 ··· 349 348 350 349 boot.kernelModules = ["br_netfilter" "overlay"]; 351 350 352 - services.kubernetes.kubelet.hostname = with config.networking; 353 - mkDefault (hostName + optionalString (domain != null) ".${domain}"); 351 + services.kubernetes.kubelet.hostname = 352 + mkDefault config.networking.fqdnOrHostName; 354 353 355 354 services.kubernetes.pki.certs = with top.lib; { 356 355 kubelet = mkCert {
+1 -2
nixos/modules/services/monitoring/smartd.nix
··· 4 4 5 5 let 6 6 7 - host = config.networking.hostName or "unknown" 8 - + optionalString (config.networking.domain != null) ".${config.networking.domain}"; 7 + host = config.networking.fqdnOrHostName; 9 8 10 9 cfg = config.services.smartd; 11 10 opt = options.services.smartd;
+2 -4
nixos/modules/services/networking/flannel.nix
··· 92 92 Needed when running with Kubernetes as backend as this cannot be auto-detected"; 93 93 ''; 94 94 type = types.nullOr types.str; 95 - default = with config.networking; (hostName + optionalString (domain != null) ".${domain}"); 96 - defaultText = literalExpression '' 97 - with config.networking; (hostName + optionalString (domain != null) ".''${domain}") 98 - ''; 95 + default = config.networking.fqdnOrHostName; 96 + defaultText = literalExpression "config.networking.fqdnOrHostName"; 99 97 example = "node1.example.com"; 100 98 }; 101 99
+1 -1
nixos/modules/services/networking/jitsi-videobridge.nix
··· 150 150 config = { 151 151 hostName = mkDefault name; 152 152 mucNickname = mkDefault (builtins.replaceStrings [ "." ] [ "-" ] ( 153 - config.networking.hostName + optionalString (config.networking.domain != null) ".${config.networking.domain}" 153 + config.networking.fqdnOrHostName 154 154 )); 155 155 }; 156 156 }));
+2 -5
nixos/modules/services/web-apps/bookstack.nix
··· 60 60 61 61 hostname = lib.mkOption { 62 62 type = lib.types.str; 63 - default = if config.networking.domain != null then 64 - config.networking.fqdn 65 - else 66 - config.networking.hostName; 67 - defaultText = lib.literalExpression "config.networking.fqdn"; 63 + default = config.networking.fqdnOrHostName; 64 + defaultText = lib.literalExpression "config.networking.fqdnOrHostName"; 68 65 example = "bookstack.example.com"; 69 66 description = lib.mdDoc '' 70 67 The hostname to serve BookStack on.
+2 -5
nixos/modules/services/web-apps/discourse.nix
··· 42 42 43 43 hostname = lib.mkOption { 44 44 type = lib.types.str; 45 - default = if config.networking.domain != null then 46 - config.networking.fqdn 47 - else 48 - config.networking.hostName; 49 - defaultText = lib.literalExpression "config.networking.fqdn"; 45 + default = config.networking.fqdnOrHostName; 46 + defaultText = lib.literalExpression "config.networking.fqdnOrHostName"; 50 47 example = "discourse.example.com"; 51 48 description = lib.mdDoc '' 52 49 The hostname to serve Discourse on.
+2 -6
nixos/modules/services/web-apps/matomo.nix
··· 12 12 phpExecutionUnit = "phpfpm-${pool}"; 13 13 databaseService = "mysql.service"; 14 14 15 - fqdn = if config.networking.domain != null then config.networking.fqdn else config.networking.hostName; 16 - 17 15 in { 18 16 imports = [ 19 17 (mkRenamedOptionModule [ "services" "piwik" "enable" ] [ "services" "matomo" "enable" ]) ··· 77 75 78 76 hostname = mkOption { 79 77 type = types.str; 80 - default = "${user}.${fqdn}"; 78 + default = "${user}.${config.networking.fqdnOrHostName}"; 81 79 defaultText = literalExpression '' 82 - if config.${options.networking.domain} != null 83 - then "${user}.''${config.${options.networking.fqdn}}" 84 - else "${user}.''${config.${options.networking.hostName}}" 80 + "${user}.''${config.${options.networking.fqdnOrHostName}}" 85 81 ''; 86 82 example = "matomo.yourdomain.org"; 87 83 description = lib.mdDoc ''
+2 -5
nixos/modules/services/web-apps/snipe-it.nix
··· 54 54 55 55 hostName = lib.mkOption { 56 56 type = lib.types.str; 57 - default = if config.networking.domain != null then 58 - config.networking.fqdn 59 - else 60 - config.networking.hostName; 61 - defaultText = lib.literalExpression "config.networking.fqdn"; 57 + default = config.networking.fqdnOrHostName; 58 + defaultText = lib.literalExpression "config.networking.fqdnOrHostName"; 62 59 example = "snipe-it.example.com"; 63 60 description = lib.mdDoc '' 64 61 The hostname to serve Snipe-IT on.
+21 -1
nixos/modules/tasks/network-interfaces.nix
··· 473 473 defaultText = literalExpression ''"''${networking.hostName}.''${networking.domain}"''; 474 474 description = lib.mdDoc '' 475 475 The fully qualified domain name (FQDN) of this host. It is the result 476 - of combining networking.hostName and networking.domain. Using this 476 + of combining `networking.hostName` and `networking.domain.` Using this 477 477 option will result in an evaluation error if the hostname is empty or 478 478 no domain is specified. 479 + 480 + Modules that accept a mere `networing.hostName` but prefer a fully qualified 481 + domain name may use `networking.fqdnOrHostName` instead. 482 + ''; 483 + }; 484 + 485 + networking.fqdnOrHostName = mkOption { 486 + readOnly = true; 487 + type = types.str; 488 + default = if cfg.domain == null then cfg.hostName else cfg.fqdn; 489 + defaultText = literalExpression '' 490 + if cfg.domain == null then cfg.hostName else cfg.fqdn 491 + ''; 492 + description = lib.mdDoc '' 493 + Either the fully qualified domain name (FQDN), or just the host name if 494 + it does not exists. 495 + 496 + This is a convenience option for modules to read instead of `fqdn` when 497 + a mere `hostName` is also an acceptable value; this option does not 498 + throw an error when `domain` is unset. 479 499 ''; 480 500 }; 481 501