about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoachim F <joachifm@users.noreply.github.com>2016-09-23 15:19:49 +0200
committerGitHub <noreply@github.com>2016-09-23 15:19:49 +0200
commit7529fd3bff8e3aee5fbdc293922379de81c2cb85 (patch)
treee2f37000cb9bb7a306bcb0a5d9e6a05090f69b3b
parent24135d60724b4ad8b0b15dd9b2082ae9355e193d (diff)
parente23cc550b32a712d2397d005c7a906d6abf35a03 (diff)
downloadnixlib-7529fd3bff8e3aee5fbdc293922379de81c2cb85.tar
nixlib-7529fd3bff8e3aee5fbdc293922379de81c2cb85.tar.gz
nixlib-7529fd3bff8e3aee5fbdc293922379de81c2cb85.tar.bz2
nixlib-7529fd3bff8e3aee5fbdc293922379de81c2cb85.tar.lz
nixlib-7529fd3bff8e3aee5fbdc293922379de81c2cb85.tar.xz
nixlib-7529fd3bff8e3aee5fbdc293922379de81c2cb85.tar.zst
nixlib-7529fd3bff8e3aee5fbdc293922379de81c2cb85.zip
Merge pull request #18818 from Jookia/RFC_htpdate
Rfc htpdate
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/networking/htpdate.nix80
-rw-r--r--pkgs/tools/networking/htpdate/default.nix24
-rw-r--r--pkgs/top-level/all-packages.nix2
4 files changed, 107 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 7064dcd968ae..a3bbddfcdd21 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -354,6 +354,7 @@
   ./services/networking/haproxy.nix
   ./services/networking/heyefi.nix
   ./services/networking/hostapd.nix
+  ./services/networking/htpdate.nix
   ./services/networking/i2pd.nix
   ./services/networking/i2p.nix
   ./services/networking/iodine.nix
diff --git a/nixos/modules/services/networking/htpdate.nix b/nixos/modules/services/networking/htpdate.nix
new file mode 100644
index 000000000000..f5d512c7cd5a
--- /dev/null
+++ b/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 = "/var/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}"
+        ];
+      };
+    };
+
+  };
+
+}
diff --git a/pkgs/tools/networking/htpdate/default.nix b/pkgs/tools/networking/htpdate/default.nix
new file mode 100644
index 000000000000..10ed8f34e3a6
--- /dev/null
+++ b/pkgs/tools/networking/htpdate/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, coreutils, binutils }:
+
+stdenv.mkDerivation rec {
+  version = "1.1.3";
+  name = "htpdate-${version}";
+
+  src = fetchurl {
+    url = "http://twekkel.home.xs4all.nl/htp/htpdate-${version}.tar.gz";
+    sha256 = "0hfg4qrsmpqw03m9qwf3zgi4brbf65w6wd3w30nkamc7x8b4vn5i";
+  };
+
+  installFlags = [
+    "INSTALL=${coreutils}/bin/install"
+    "STRIP=${binutils}/bin/strip"
+    "prefix=$(out)"
+  ];
+
+  meta = {
+    description = "Utility to fetch time and set the system clock over HTTP";
+    homepage = http://www.vervest.org/htp/;
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.gpl2Plus;
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 4d8645639852..2017f6e4faec 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -2066,6 +2066,8 @@ in
 
   hping = callPackage ../tools/networking/hping { };
 
+  htpdate = callPackage ../tools/networking/htpdate { };
+
   http-prompt = callPackage ../tools/networking/http-prompt { };
 
   httpie = callPackage ../tools/networking/httpie { };