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

nixos: Add `networking.fqdnOrHostName`

Changed files
+36 -33
nixos
modules
+3 -4
nixos/modules/services/cluster/kubernetes/kubelet.nix
···
hostname = mkOption {
description = lib.mdDoc "Kubernetes kubelet hostname override.";
-
default = config.networking.hostName;
-
defaultText = literalExpression "config.networking.hostName";
type = str;
};
···
boot.kernelModules = ["br_netfilter" "overlay"];
-
services.kubernetes.kubelet.hostname = with config.networking;
-
mkDefault (hostName + optionalString (domain != null) ".${domain}");
services.kubernetes.pki.certs = with top.lib; {
kubelet = mkCert {
···
hostname = mkOption {
description = lib.mdDoc "Kubernetes kubelet hostname override.";
+
defaultText = literalExpression "config.networking.fqdnOrHostName";
type = str;
};
···
boot.kernelModules = ["br_netfilter" "overlay"];
+
services.kubernetes.kubelet.hostname =
+
mkDefault config.networking.fqdnOrHostName;
services.kubernetes.pki.certs = with top.lib; {
kubelet = mkCert {
+1 -2
nixos/modules/services/monitoring/smartd.nix
···
let
-
host = config.networking.hostName or "unknown"
-
+ optionalString (config.networking.domain != null) ".${config.networking.domain}";
cfg = config.services.smartd;
opt = options.services.smartd;
···
let
+
host = config.networking.fqdnOrHostName;
cfg = config.services.smartd;
opt = options.services.smartd;
+2 -4
nixos/modules/services/networking/flannel.nix
···
Needed when running with Kubernetes as backend as this cannot be auto-detected";
'';
type = types.nullOr types.str;
-
default = with config.networking; (hostName + optionalString (domain != null) ".${domain}");
-
defaultText = literalExpression ''
-
with config.networking; (hostName + optionalString (domain != null) ".''${domain}")
-
'';
example = "node1.example.com";
};
···
Needed when running with Kubernetes as backend as this cannot be auto-detected";
'';
type = types.nullOr types.str;
+
default = config.networking.fqdnOrHostName;
+
defaultText = literalExpression "config.networking.fqdnOrHostName";
example = "node1.example.com";
};
+1 -1
nixos/modules/services/networking/jitsi-videobridge.nix
···
config = {
hostName = mkDefault name;
mucNickname = mkDefault (builtins.replaceStrings [ "." ] [ "-" ] (
-
config.networking.hostName + optionalString (config.networking.domain != null) ".${config.networking.domain}"
));
};
}));
···
config = {
hostName = mkDefault name;
mucNickname = mkDefault (builtins.replaceStrings [ "." ] [ "-" ] (
+
config.networking.fqdnOrHostName
));
};
}));
+2 -5
nixos/modules/services/web-apps/bookstack.nix
···
hostname = lib.mkOption {
type = lib.types.str;
-
default = if config.networking.domain != null then
-
config.networking.fqdn
-
else
-
config.networking.hostName;
-
defaultText = lib.literalExpression "config.networking.fqdn";
example = "bookstack.example.com";
description = lib.mdDoc ''
The hostname to serve BookStack on.
···
hostname = lib.mkOption {
type = lib.types.str;
+
default = config.networking.fqdnOrHostName;
+
defaultText = lib.literalExpression "config.networking.fqdnOrHostName";
example = "bookstack.example.com";
description = lib.mdDoc ''
The hostname to serve BookStack on.
+2 -5
nixos/modules/services/web-apps/discourse.nix
···
hostname = lib.mkOption {
type = lib.types.str;
-
default = if config.networking.domain != null then
-
config.networking.fqdn
-
else
-
config.networking.hostName;
-
defaultText = lib.literalExpression "config.networking.fqdn";
example = "discourse.example.com";
description = lib.mdDoc ''
The hostname to serve Discourse on.
···
hostname = lib.mkOption {
type = lib.types.str;
+
default = config.networking.fqdnOrHostName;
+
defaultText = lib.literalExpression "config.networking.fqdnOrHostName";
example = "discourse.example.com";
description = lib.mdDoc ''
The hostname to serve Discourse on.
+2 -6
nixos/modules/services/web-apps/matomo.nix
···
phpExecutionUnit = "phpfpm-${pool}";
databaseService = "mysql.service";
-
fqdn = if config.networking.domain != null then config.networking.fqdn else config.networking.hostName;
-
in {
imports = [
(mkRenamedOptionModule [ "services" "piwik" "enable" ] [ "services" "matomo" "enable" ])
···
hostname = mkOption {
type = types.str;
-
default = "${user}.${fqdn}";
defaultText = literalExpression ''
-
if config.${options.networking.domain} != null
-
then "${user}.''${config.${options.networking.fqdn}}"
-
else "${user}.''${config.${options.networking.hostName}}"
'';
example = "matomo.yourdomain.org";
description = lib.mdDoc ''
···
phpExecutionUnit = "phpfpm-${pool}";
databaseService = "mysql.service";
in {
imports = [
(mkRenamedOptionModule [ "services" "piwik" "enable" ] [ "services" "matomo" "enable" ])
···
hostname = mkOption {
type = types.str;
+
default = "${user}.${config.networking.fqdnOrHostName}";
defaultText = literalExpression ''
+
"${user}.''${config.${options.networking.fqdnOrHostName}}"
'';
example = "matomo.yourdomain.org";
description = lib.mdDoc ''
+2 -5
nixos/modules/services/web-apps/snipe-it.nix
···
hostName = lib.mkOption {
type = lib.types.str;
-
default = if config.networking.domain != null then
-
config.networking.fqdn
-
else
-
config.networking.hostName;
-
defaultText = lib.literalExpression "config.networking.fqdn";
example = "snipe-it.example.com";
description = lib.mdDoc ''
The hostname to serve Snipe-IT on.
···
hostName = lib.mkOption {
type = lib.types.str;
+
default = config.networking.fqdnOrHostName;
+
defaultText = lib.literalExpression "config.networking.fqdnOrHostName";
example = "snipe-it.example.com";
description = lib.mdDoc ''
The hostname to serve Snipe-IT on.
+21 -1
nixos/modules/tasks/network-interfaces.nix
···
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
option will result in an evaluation error if the hostname is empty or
no domain is specified.
'';
};
···
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
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.
'';
};