aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/services/networking/htpdate.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/networking/htpdate.nix')
-rw-r--r--nixpkgs/nixos/modules/services/networking/htpdate.nix80
1 files changed, 80 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/services/networking/htpdate.nix b/nixpkgs/nixos/modules/services/networking/htpdate.nix
new file mode 100644
index 00000000000..6954e5b060c
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/networking/htpdate.nix
@@ -0,0 +1,80 @@
+{ 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;
+ description = ''
+ Enable htpdate daemon.
+ '';
+ };
+
+ extraOptions = mkOption {
+ type = types.str;
+ default = "";
+ description = ''
+ Additional command line arguments to pass to htpdate.
+ '';
+ };
+
+ servers = mkOption {
+ type = types.listOf types.str;
+ default = [ "www.google.com" ];
+ description = ''
+ HTTP servers to use for time synchronization.
+ '';
+ };
+
+ proxy = mkOption {
+ type = types.str;
+ default = "";
+ example = "127.0.0.1:8118";
+ description = ''
+ HTTP proxy used for requests.
+ '';
+ };
+
+ };
+
+ };
+
+ ###### implementation
+
+ config = mkIf cfg.enable {
+
+ systemd.services.htpdate = {
+ description = "htpdate daemon";
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ Type = "forking";
+ PIDFile = "/run/htpdate.pid";
+ ExecStart = concatStringsSep " " [
+ "${htpdate}/bin/htpdate"
+ "-D -u nobody"
+ "-a -s"
+ "-l"
+ "${optionalString (cfg.proxy != "") "-P ${cfg.proxy}"}"
+ "${cfg.extraOptions}"
+ "${concatStringsSep " " cfg.servers}"
+ ];
+ };
+ };
+
+ };
+
+}