Commit b4cd5787 authored by datafoo's avatar datafoo
Browse files

nixos/timesyncd: allow null for option servers

This gives the ability to not write `NTP=` to the `timesyncd.conf` file
(servers = null) as opposed to writing `NTP=` (servers = []) which is
interpreted slightly differently by systemd:

> When the empty string is assigned, the list of NTP servers is reset,
and all prior assignments will have no effect.
parent 34efcf8a
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -21,12 +21,15 @@ in
      servers = mkOption {
        default = config.networking.timeServers;
        defaultText = literalExpression "config.networking.timeServers";
        type = listOf str;
        type = nullOr (listOf str);
        description = ''
          The set of NTP servers from which to synchronise.
          Note if this is set to an empty list, the defaults systemd itself is
          compiled with ({0..4}.nixos.pool.ntp.org) apply,
          In case you want to disable timesyncd altogether, use the `enable` option.

          Setting this option to an empty list will write `NTP=` to the
          `timesyncd.conf` file as opposed to setting this option to null which
          will remove `NTP=` entirely.

          See man:timesyncd.conf(5) for details.
        '';
      };
      extraConfig = mkOption {
@@ -85,9 +88,11 @@ in

    environment.etc."systemd/timesyncd.conf".text = ''
      [Time]
    ''
    + optionalString (cfg.servers != null) ''
      NTP=${concatStringsSep " " cfg.servers}
      ${cfg.extraConfig}
    '';
    ''
    + cfg.extraConfig;

    users.users.systemd-timesync = {
      uid = config.ids.uids.systemd-timesync;