depot/nixos/modules/services/networking/htpdate.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

77 lines
1.5 KiB
Nix

{ config, lib, pkgs, ... }:
let
inherit (pkgs) htpdate;
cfg = config.services.htpdate;
in
{
###### interface
options = {
services.htpdate = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Enable htpdate daemon.
'';
};
extraOptions = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
Additional command line arguments to pass to htpdate.
'';
};
servers = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "www.google.com" ];
description = ''
HTTP servers to use for time synchronization.
'';
};
proxy = lib.mkOption {
type = lib.types.str;
default = "";
example = "127.0.0.1:8118";
description = ''
HTTP proxy used for requests.
'';
};
};
};
###### implementation
config = lib.mkIf cfg.enable {
systemd.services.htpdate = {
description = "htpdate daemon";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "forking";
PIDFile = "/run/htpdate.pid";
ExecStart = lib.concatStringsSep " " [
"${htpdate}/bin/htpdate"
"-D -u nobody"
"-a -s"
"-l"
"${lib.optionalString (cfg.proxy != "") "-P ${cfg.proxy}"}"
"${cfg.extraOptions}"
"${lib.concatStringsSep " " cfg.servers}"
];
};
};
};
}