2014-09-01 15:14:00 +02:00
|
|
|
{ pkgs, lib, config, options, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.openntpd;
|
|
|
|
|
|
|
|
package = pkgs.openntpd.override {
|
|
|
|
privsepUser = "ntp";
|
|
|
|
privsepPath = "/var/empty";
|
|
|
|
};
|
|
|
|
|
|
|
|
cfgFile = pkgs.writeText "openntpd.conf" ''
|
|
|
|
${concatStringsSep "\n" (map (s: "server ${s}") cfg.servers)}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options.services.openntpd = {
|
|
|
|
enable = mkEnableOption "OpenNTP time synchronization server";
|
|
|
|
|
|
|
|
servers = mkOption {
|
|
|
|
default = config.services.ntp.servers;
|
|
|
|
type = types.listOf types.str;
|
|
|
|
inherit (options.services.ntp.servers) description;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.ntp.enable = mkForce false;
|
|
|
|
|
|
|
|
users.extraUsers = singleton {
|
|
|
|
name = "ntp";
|
|
|
|
uid = config.ids.uids.ntp;
|
|
|
|
description = "OpenNTP daemon user";
|
|
|
|
home = "/var/empty";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.openntpd = {
|
|
|
|
description = "OpenNTP Server";
|
2014-11-26 20:19:31 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2014-09-01 15:14:00 +02:00
|
|
|
serviceConfig.ExecStart = "${package}/sbin/ntpd -d -f ${cfgFile}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|