diff options
author | nikstur <nikstur@outlook.com> | 2023-10-25 00:06:46 +0200 |
---|---|---|
committer | nikstur <nikstur@outlook.com> | 2023-10-26 01:51:08 +0200 |
commit | d300940637a74421b78d3e94b25daf35f1b9ec9d (patch) | |
tree | a4e960b1282343d2abdf95819ec2073809800db2 /nixos/modules | |
parent | b5617e0575c36b16779e2948518d0fc299198ebb (diff) |
nixos/network-interfaces: replace hostname and domain activationScript
The hostname is already set by systemd https://www.freedesktop.org/software/systemd/man/latest/hostname.html#Hostname%20semantics Create a separate service that registers the domainname.
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/tasks/network-interfaces.nix | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index 853a2cb31432b..a0e8e5d47a604 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -1406,18 +1406,12 @@ in val = tempaddrValues.${opt}.sysctl; in nameValuePair "net.ipv6.conf.${replaceStrings ["."] ["/"] i.name}.use_tempaddr" val)); - # 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 = let - effectiveHostname = config.boot.kernel.sysctl."kernel.hostname" or cfg.hostName; - in optionalString (effectiveHostname != "") '' - hostname "${effectiveHostname}" - ''; - system.activationScripts.domain = - optionalString (cfg.domain != null) '' - domainname "${cfg.domain}" - ''; + systemd.services.domainname = lib.mkIf (cfg.domain != null) { + wantedBy = [ "sysinit.target" ]; + before = [ "sysinit.target" ]; + unitConfig.DefaultDependencies = false; + serviceConfig.ExecStart = ''domainname "${cfg.domain}"''; + }; environment.etc.hostid = mkIf (cfg.hostId != null) { source = hostidFile; }; boot.initrd.systemd.contents."/etc/hostid" = mkIf (cfg.hostId != null) { source = hostidFile; }; |