12 cfg = config.services.openntpd;
14 package = pkgs.openntpd_nixos;
17 ${concatStringsSep "\n" (map (s: "server ${s}") cfg.servers)}
21 pidFile = "/run/openntpd.pid";
27 options.services.openntpd = {
28 enable = mkEnableOption "OpenNTP time synchronization server";
31 default = config.services.ntp.servers;
32 defaultText = literalExpression "config.services.ntp.servers";
33 type = types.listOf types.str;
34 inherit (options.services.ntp.servers) description;
37 extraConfig = mkOption {
38 type = with types; lines;
45 Additional text appended to {file}`openntpd.conf`.
49 extraOptions = mkOption {
50 type = with types; separatedString " ";
54 Extra options used when launching openntpd.
61 config = mkIf cfg.enable {
62 meta.maintainers = with lib.maintainers; [ thoughtpolice ];
63 services.timesyncd.enable = mkForce false;
65 # Add ntpctl to the environment for status checking
66 environment.systemPackages = [ package ];
68 environment.etc."ntpd.conf".text = configFile;
73 description = "OpenNTP daemon user";
76 users.groups.ntp = { };
78 systemd.services.openntpd = {
79 description = "OpenNTP Server";
80 wantedBy = [ "multi-user.target" ];
82 "network-online.target"
85 before = [ "time-sync.target" ];
89 "network-online.target"
92 ExecStart = "${package}/sbin/ntpd -p ${pidFile} ${cfg.extraOptions}";