at 25.11-pre 1.6 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7let 8 inherit (pkgs) htpdate; 9 10 cfg = config.services.htpdate; 11in 12 13{ 14 15 ###### interface 16 17 options = { 18 19 services.htpdate = { 20 21 enable = lib.mkOption { 22 type = lib.types.bool; 23 default = false; 24 description = '' 25 Enable htpdate daemon. 26 ''; 27 }; 28 29 extraOptions = lib.mkOption { 30 type = lib.types.str; 31 default = ""; 32 description = '' 33 Additional command line arguments to pass to htpdate. 34 ''; 35 }; 36 37 servers = lib.mkOption { 38 type = lib.types.listOf lib.types.str; 39 default = [ "www.google.com" ]; 40 description = '' 41 HTTP servers to use for time synchronization. 42 ''; 43 }; 44 45 proxy = lib.mkOption { 46 type = lib.types.str; 47 default = ""; 48 example = "127.0.0.1:8118"; 49 description = '' 50 HTTP proxy used for requests. 51 ''; 52 }; 53 54 }; 55 56 }; 57 58 ###### implementation 59 60 config = lib.mkIf cfg.enable { 61 62 systemd.services.htpdate = { 63 description = "htpdate daemon"; 64 wantedBy = [ "multi-user.target" ]; 65 serviceConfig = { 66 Type = "forking"; 67 PIDFile = "/run/htpdate.pid"; 68 ExecStart = lib.concatStringsSep " " [ 69 "${htpdate}/bin/htpdate" 70 "-D -u nobody" 71 "-a -s" 72 "-l" 73 "${lib.optionalString (cfg.proxy != "") "-P ${cfg.proxy}"}" 74 "${cfg.extraOptions}" 75 "${lib.concatStringsSep " " cfg.servers}" 76 ]; 77 }; 78 }; 79 80 }; 81 82}