It is generally possible to receive NTP servers through DHCP (RFC 2132). Other distros like Debian already support such a automatic NTP configuration. I think it would be great if NixOS does it well.
On Debian based systems there is a request option inside the /etc/dhcp/dhclient.conf file which configures all attributes like ntp-servers. A simple dhclient eth0 restarts ntp with the new configuration (which is stored under /var/lib/ntp/ntp.conf.dhcp)
I've no idea how to implement this feature in NixOS because NTP's config file is hard coded in the systemd service. Any ideas?
I don't know how it works, but it seems in isolation like the right way forward is to un-hardcode the ntp config and make a separate (configurable) module for it.
Make sure this works for openntpd and ntpd. systemd-timesyncd should get it's information from systemd-networkd so it shouldn't be an issue.
(triage) anyone? Otherwise I suggest we close.
I don't think closing is appropriate. This seems to be a valid use case.
I propose in this pull request to use timesyncd by default: https://github.com/NixOS/nixpkgs/pull/21160
this means that networkd is missing to make it complete.
Most helpful comment
I don't think closing is appropriate. This seems to be a valid use case.