at 23.11-pre 1.6 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 inherit (pkgs) htpdate; 7 8 cfg = config.services.htpdate; 9in 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 = lib.mdDoc '' 23 Enable htpdate daemon. 24 ''; 25 }; 26 27 extraOptions = mkOption { 28 type = types.str; 29 default = ""; 30 description = lib.mdDoc '' 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 = lib.mdDoc '' 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 = lib.mdDoc '' 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 = "/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}