git.iko.soy/typeable/nixpkgs
on master help sign in
nixos: add htpdate module
commite23cc550b32a712d2397d005c7a906d6abf35a03 authorJookia <166291@gmail.com> dateWed 3 Aug 2016, 08:57 (10 years ago) parenta83eadd
2 files changed+81
nixos/modules/module-list.nix+1 nixos/modules/services/networking/htpdate.nix+80
nixos/modules/module-list.nix+1
@@ -354,6 +354,7 @@
354354 ./services/networking/haproxy.nix
355355 ./services/networking/heyefi.nix
356356 ./services/networking/hostapd.nix
357+ ./services/networking/htpdate.nix
357358 ./services/networking/i2pd.nix
358359 ./services/networking/i2p.nix
359360 ./services/networking/iodine.nix
nixos/modules/services/networking/htpdate.nixnew file+80
@@ -0,0 +1,80 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ inherit (pkgs) htpdate;
7+
8+ cfg = config.services.htpdate;
9+in
10+
11+{
12+
13+ ###### interface
14+
15+ options = {
16+
17+ services.htpdate = {
18+
19+ enable = mkOption {
20+ type = types.bool;
21+ default = false;
22+ description = ''
23+ Enable htpdate daemon.
24+ '';
25+ };
26+
27+ extraOptions = mkOption {
28+ type = types.str;
29+ default = "";
30+ description = ''
31+ Additional command line arguments to pass to htpdate.
32+ '';
33+ };
34+
35+ servers = mkOption {
36+ type = types.listOf types.str;
37+ default = [ "www.google.com" ];
38+ description = ''
39+ HTTP servers to use for time synchronization.
40+ '';
41+ };
42+
43+ proxy = mkOption {
44+ type = types.str;
45+ default = "";
46+ example = "127.0.0.1:8118";
47+ description = ''
48+ HTTP proxy used for requests.
49+ '';
50+ };
51+
52+ };
53+
54+ };
55+
56+ ###### implementation
57+
58+ config = mkIf cfg.enable {
59+
60+ systemd.services.htpdate = {
61+ description = "htpdate daemon";
62+ wantedBy = [ "multi-user.target" ];
63+ serviceConfig = {
64+ Type = "forking";
65+ PIDFile = "/var/run/htpdate.pid";
66+ ExecStart = concatStringsSep " " [
67+ "${htpdate}/bin/htpdate"
68+ "-D -u nobody"
69+ "-a -s"
70+ "-l"
71+ "${optionalString (cfg.proxy != "") "-P ${cfg.proxy}"}"
72+ "${cfg.extraOptions}"
73+ "${concatStringsSep " " cfg.servers}"
74+ ];
75+ };
76+ };
77+
78+ };
79+
80+}