2016-08-03 00:57:20 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (pkgs) htpdate;
|
|
|
|
|
|
|
|
cfg = config.services.htpdate;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.htpdate = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2016-08-03 00:57:20 +02:00
|
|
|
Enable htpdate daemon.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2016-08-03 00:57:20 +02:00
|
|
|
Additional command line arguments to pass to htpdate.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
servers = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ "www.google.com" ];
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2016-08-03 00:57:20 +02:00
|
|
|
HTTP servers to use for time synchronization.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
proxy = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
example = "127.0.0.1:8118";
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2016-08-03 00:57:20 +02:00
|
|
|
HTTP proxy used for requests.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
systemd.services.htpdate = {
|
|
|
|
description = "htpdate daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "forking";
|
2018-12-19 22:39:47 +01:00
|
|
|
PIDFile = "/run/htpdate.pid";
|
2016-08-03 00:57:20 +02:00
|
|
|
ExecStart = concatStringsSep " " [
|
|
|
|
"${htpdate}/bin/htpdate"
|
|
|
|
"-D -u nobody"
|
|
|
|
"-a -s"
|
|
|
|
"-l"
|
|
|
|
"${optionalString (cfg.proxy != "") "-P ${cfg.proxy}"}"
|
|
|
|
"${cfg.extraOptions}"
|
|
|
|
"${concatStringsSep " " cfg.servers}"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|