Merge pull request #117371 from grahamc/sysctl-hostname

network-interfaces: set hostname from sysctl if defined
This commit is contained in:
Ryan Lahfa
2022-12-01 16:03:04 +01:00
committed by GitHub
+4 -3
View File
@@ -1411,9 +1411,10 @@ in
# Set the host and domain names in the activation script. Don't
# clear it if it's not configured in the NixOS configuration,
# since it may have been set by dhcpcd in the meantime.
system.activationScripts.hostname =
optionalString (cfg.hostName != "") ''
hostname "${cfg.hostName}"
system.activationScripts.hostname = let
effectiveHostname = config.boot.kernel.sysctl."kernel.hostname" or cfg.hostName;
in optionalString (effectiveHostname != "") ''
hostname "${effectiveHostname}"
'';
system.activationScripts.domain =
optionalString (cfg.domain != null) ''