unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#38145] [PATCH 0/3] Add knot-resolver and knot-resolver-service-type.
@ 2019-11-09  9:16 宋文武
  2019-11-09  9:19 ` [bug#38145] [PATCH 1/3] gnu: Add python-breathe 宋文武
  2019-11-11 12:32 ` bug#38145: [PATCH 0/3] Add knot-resolver and knot-resolver-service-type 宋文武
  0 siblings, 2 replies; 5+ messages in thread
From: 宋文武 @ 2019-11-09  9:16 UTC (permalink / raw)
  To: 38145; +Cc: 宋文武

Hello, here are patches to add knot-resolver, it's a caching and
recursive DNS server, just like unbound.

Sou Bunnbu (宋文武) (3):
  gnu: Add python-breathe.
  gnu: Add knot-resolver.
  services: Add knot-resolver-service-type.

 doc/guix.texi           | 38 ++++++++++++++++++
 gnu/packages/dns.scm    | 72 ++++++++++++++++++++++++++++++++++
 gnu/packages/sphinx.scm | 22 +++++++++++
 gnu/services/dns.scm    | 86 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 218 insertions(+)

--
2.19.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [bug#38145] [PATCH 1/3] gnu: Add python-breathe.
  2019-11-09  9:16 [bug#38145] [PATCH 0/3] Add knot-resolver and knot-resolver-service-type 宋文武
@ 2019-11-09  9:19 ` 宋文武
  2019-11-09  9:19   ` [bug#38145] [PATCH 2/3] gnu: Add knot-resolver 宋文武
  2019-11-09  9:19   ` [bug#38145] [PATCH 3/3] services: Add knot-resolver-service-type 宋文武
  2019-11-11 12:32 ` bug#38145: [PATCH 0/3] Add knot-resolver and knot-resolver-service-type 宋文武
  1 sibling, 2 replies; 5+ messages in thread
From: 宋文武 @ 2019-11-09  9:19 UTC (permalink / raw)
  To: 38145; +Cc: 宋文武

* gnu/packages/sphinx.scm (python-breathe): New package.
---
 gnu/packages/sphinx.scm | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gnu/packages/sphinx.scm b/gnu/packages/sphinx.scm
index da7492c42e..8c658c286d 100644
--- a/gnu/packages/sphinx.scm
+++ b/gnu/packages/sphinx.scm
@@ -541,3 +541,25 @@ and several other projects.")
 
 (define-public python2-sphinx-rtd-theme
   (package-with-python2 python-sphinx-rtd-theme))
+
+(define-public python-breathe
+  (package
+    (name "python-breathe")
+    (version "4.13.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "breathe" version))
+       (sha256
+        (base32
+         "1aw749n2ry27434qd7gr99dvsrs3x3chyi9aywmhjj1g4m2j6xf6"))))
+    (build-system python-build-system)
+    (propagated-inputs
+     `(("python-docutils" ,python-docutils)
+       ("python-six" ,python-six)
+       ("python-sphinx" ,python-sphinx)))
+    (home-page "https://github.com/michaeljones/breathe")
+    (synopsis "ReStructuredText and Sphinx bridge to Doxygen")
+    (description "This package is an extension to reStructuredText and Sphinx
+to be able to read and render the Doxygen xml output.")
+    (license license:bsd-3)))
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#38145] [PATCH 2/3] gnu: Add knot-resolver.
  2019-11-09  9:19 ` [bug#38145] [PATCH 1/3] gnu: Add python-breathe 宋文武
@ 2019-11-09  9:19   ` 宋文武
  2019-11-09  9:19   ` [bug#38145] [PATCH 3/3] services: Add knot-resolver-service-type 宋文武
  1 sibling, 0 replies; 5+ messages in thread
From: 宋文武 @ 2019-11-09  9:19 UTC (permalink / raw)
  To: 38145; +Cc: 宋文武

* gnu/packages/dns.scm (knot-resolver): New package.
---
 gnu/packages/dns.scm | 72 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/gnu/packages/dns.scm b/gnu/packages/dns.scm
index ec4008bf19..8be7205fa1 100644
--- a/gnu/packages/dns.scm
+++ b/gnu/packages/dns.scm
@@ -34,7 +34,9 @@
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages check)
   #:use-module (gnu packages databases)
+  #:use-module (gnu packages documentation)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages crypto)
   #:use-module (gnu packages datastructures)
@@ -46,6 +48,7 @@
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages libidn)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages lua)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages nettle)
   #:use-module (gnu packages networking)
@@ -54,6 +57,7 @@
   #:use-module (gnu packages protobuf)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages sphinx)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages web)
@@ -65,6 +69,7 @@
   #:use-module (guix git-download)
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system meson)
   #:use-module (guix build-system trivial))
 
 (define-public dnsmasq
@@ -662,6 +667,73 @@ synthesis, and on-the-fly re-configuration.")
       license:public-domain         ; src/contrib/fnv and possibly murmurhash3
       license:gpl3+))))             ; everything else
 
+(define-public knot-resolver
+  (package
+    (name "knot-resolver")
+    (version "4.2.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://secure.nic.cz/files/knot-resolver/"
+                                  "knot-resolver-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0n0llpclhparq9wbcrymxkl5d03c4y4p3shcbdxfv6j22vzqvdh3"))))
+    (build-system meson-build-system)
+    (arguments
+     '(#:configure-flags
+       ;; We'll manage the DNS root data ourself.
+       '("-Dmanaged_ta=disabled")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'build 'build-doc
+           (lambda _
+             (invoke "ninja" "doc")))
+         (add-after 'install 'wrap-binary
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (lua-* (map cdr (filter
+                                     (lambda (input)
+                                       (string-prefix? "lua-" (car input)))
+                                     inputs)))
+                    (lua-path (lambda (p)
+                                (string-append p "/share/lua/5.1/?.lua")))
+                    (lua-cpath (lambda (p)
+                                 (string-append p "/lib/lua/5.1/?.so"))))
+               (wrap-program (string-append out "/sbin/kresd")
+                 `("LUA_PATH" ";" prefix ,(map lua-path lua-*))
+                 `("LUA_CPATH" ";" prefix ,(map lua-cpath lua-*)))
+               #t))))))
+    (native-inputs
+     `(("cmocka" ,cmocka)               ; for unit tests
+       ("doxygen" ,doxygen)
+       ("protobuf-c" ,protobuf-c)
+       ("pkg-config" ,pkg-config)
+       ("python-breathe" ,python-breathe)
+       ("python-sphinx" ,python-sphinx)
+       ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)))
+    (inputs
+     `(("fstrm" ,fstrm)
+       ("gnutls" ,gnutls)
+       ("knot" ,knot)
+       ("libuv" ,libuv)
+       ("lmdb" ,lmdb)
+       ("luajit" ,luajit)
+       ;; TODO: Add optional lua modules: basexx, cqueues and psl.
+       ("lua-bitop" ,lua5.1-bitop)
+       ("lua-filesystem" ,lua5.1-filesystem)
+       ("lua-sec" ,lua5.1-sec)
+       ("lua-socket" ,lua5.1-socket)))
+    (home-page "https://www.knot-resolver.cz/")
+    (synopsis "Caching validating DNS resolver")
+    (description
+     "Knot Resolver is a caching full resolver implementation written in C and
+LuaJIT, both a resolver library and a daemon.")
+    (license (list license:gpl3+
+                   ;; Some 'contrib' files are under MIT, CC0 and LGPL2.
+                   license:expat
+                   license:cc0
+                   license:lgpl2.0))))
+
 (define-public ddclient
   (package
     (name "ddclient")
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#38145] [PATCH 3/3] services: Add knot-resolver-service-type.
  2019-11-09  9:19 ` [bug#38145] [PATCH 1/3] gnu: Add python-breathe 宋文武
  2019-11-09  9:19   ` [bug#38145] [PATCH 2/3] gnu: Add knot-resolver 宋文武
@ 2019-11-09  9:19   ` 宋文武
  1 sibling, 0 replies; 5+ messages in thread
From: 宋文武 @ 2019-11-09  9:19 UTC (permalink / raw)
  To: 38145; +Cc: 宋文武

* gnu/services/dns.scm (<knot-resolver-configuration>): New record type.
(knot-resolver-activation, knot-resolver-shpherd-services): New procedures.
(%knot-resolver-accounts, %kresd.conf, knot-resolver-service-type): New
variables.
* doc/guix.texi (DNS Services): Document it.
---
 doc/guix.texi        | 38 ++++++++++++++++++++
 gnu/services/dns.scm | 86 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 124 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 27cb31dde5..5ad259c46e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -21085,6 +21085,44 @@ The list of knot-zone-configuration used by this configuration.
 @end table
 @end deftp
 
+@subsubheading Knot Resolver Service
+
+@deffn {Scheme Variable} knot-resolver-service-type
+This this the type of the knot resolver service, whose value should be
+an @code{knot-resolver-configuration} object as in this example:
+
+@lisp
+(service knot-resolver-service-type
+         (knot-resolver-configuration
+           (kresd-config-file (plain-file "kresd.conf" "
+net.listen('192.168.0.1', 5353)
+user('knot-resolver', 'knot-resolver')
+modules = @{ 'hints > iterate', 'stats', 'predict' @}
+cache.size = 100 * MB
+"))))
+@end lisp
+
+For more information, refer its @url{https://knot-resolver.readthedocs.org/en/stable/daemon.html#configuration, manual}.
+@end deffn
+
+@deftp {Data Type} knot-resolver-configuration
+Data type representing the configuration of knot-resolver.
+
+@table @asis
+@item @code{package} (default: @var{knot-resolver})
+Package object of the knot DNS resolver.
+
+@item @code{kresd-config-file} (default: %kresd.conf)
+File-like object of the kresd configuration file to use, by default it
+will listen on @code{127.0.0.1} and @code{::1}.
+
+@item @code{garbage-collection-interval} (default: 1000)
+Number of milliseconds for @code{kres-cache-gc} to periodically trim the cache.
+
+@end table
+@end deftp
+
+
 @subsubheading Dnsmasq Service
 
 @deffn {Scheme Variable} dnsmasq-service-type
diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm
index 5f37cb0782..43b6261c07 100644
--- a/gnu/services/dns.scm
+++ b/gnu/services/dns.scm
@@ -45,6 +45,9 @@
             zone-file
             zone-entry
 
+            knot-resolver-service-type
+            knot-resolver-configuration
+
             dnsmasq-service-type
             dnsmasq-configuration
 
@@ -638,6 +641,89 @@
                                            (const %knot-accounts))))))
 
 \f
+;;;
+;;; Knot Resolver.
+;;;
+
+(define-record-type* <knot-resolver-configuration>
+  knot-resolver-configuration
+  make-knot-resolver-configuration
+  knot-resolver-configuration?
+  (package knot-resolver-configuration-package
+           (default knot-resolver))
+  (kresd-config-file knot-resolver-kresd-config-file
+                     (default %kresd.conf))
+  (garbage-collection-interval knot-resolver-garbage-collection-interval
+                               (default 1000)))
+
+(define %kresd.conf
+  (plain-file "kresd.conf" "-- -*- mode: lua -*-
+net = { '127.0.0.1', '::1' }
+user('knot-resolver', 'knot-resolver')
+modules = { 'hints > iterate', 'stats', 'predict' }
+cache.size = 100 * MB
+"))
+
+(define %knot-resolver-accounts
+  (list (user-group
+         (name "knot-resolver")
+         (system? #t))
+        (user-account
+         (name "knot-resolver")
+         (group "knot-resolver")
+         (system? #t)
+         (home-directory "/var/cache/knot-resolver")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+(define (knot-resolver-activation config)
+  #~(begin
+      (use-modules (guix build utils))
+      (let ((rundir "/var/cache/knot-resolver")
+            (owner (getpwnam "knot-resolver")))
+        (mkdir-p rundir)
+        (chown rundir (passwd:uid owner) (passwd:gid owner)))))
+
+(define knot-resolver-shepherd-services
+  (match-lambda
+    (($ <knot-resolver-configuration> package
+                                      kresd-config-file
+                                      garbage-collection-interval)
+     (list
+      (shepherd-service
+       (provision '(kresd))
+       (requirement '(networking))
+       (documentation "Run the Knot Resolver daemon.")
+       (start #~(make-forkexec-constructor
+                 '(#$(file-append package "/sbin/kresd")
+                   "-c" #$kresd-config-file "-f" "1"
+                   "/var/cache/knot-resolver")))
+       (stop #~(make-kill-destructor)))
+      (shepherd-service
+       (provision '(kres-cache-gc))
+       (requirement '(user-processes))
+       (documentation "Run the Knot Resolver Garbage Collector daemon.")
+       (start #~(make-forkexec-constructor
+                 '(#$(file-append package "/sbin/kres-cache-gc")
+                   "-d" #$(number->string garbage-collection-interval)
+                   "-c" "/var/cache/knot-resolver")
+                 #:user "knot-resolver"
+                 #:group "knot-resolver"))
+       (stop #~(make-kill-destructor)))))))
+
+(define knot-resolver-service-type
+  (service-type
+   (name 'knot-resolver)
+   (extensions
+    (list (service-extension shepherd-root-service-type
+                             knot-resolver-shepherd-services)
+          (service-extension activation-service-type
+                             knot-resolver-activation)
+          (service-extension account-service-type
+                             (const %knot-resolver-accounts))))
+   (default-value (knot-resolver-configuration))
+   (description "Run the Knot DNS Resolver.")))
+
+\f
 ;;;
 ;;; Dnsmasq.
 ;;;
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#38145: [PATCH 0/3] Add knot-resolver and knot-resolver-service-type.
  2019-11-09  9:16 [bug#38145] [PATCH 0/3] Add knot-resolver and knot-resolver-service-type 宋文武
  2019-11-09  9:19 ` [bug#38145] [PATCH 1/3] gnu: Add python-breathe 宋文武
@ 2019-11-11 12:32 ` 宋文武
  1 sibling, 0 replies; 5+ messages in thread
From: 宋文武 @ 2019-11-11 12:32 UTC (permalink / raw)
  To: 38145-done

宋文武 <iyzsong@member.fsf.org> writes:

> Hello, here are patches to add knot-resolver, it's a caching and
> recursive DNS server, just like unbound.
>
> Sou Bunnbu (宋文武) (3):
>   gnu: Add python-breathe.
>   gnu: Add knot-resolver.
>   services: Add knot-resolver-service-type.
>

Pushed :-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-11 12:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-09  9:16 [bug#38145] [PATCH 0/3] Add knot-resolver and knot-resolver-service-type 宋文武
2019-11-09  9:19 ` [bug#38145] [PATCH 1/3] gnu: Add python-breathe 宋文武
2019-11-09  9:19   ` [bug#38145] [PATCH 2/3] gnu: Add knot-resolver 宋文武
2019-11-09  9:19   ` [bug#38145] [PATCH 3/3] services: Add knot-resolver-service-type 宋文武
2019-11-11 12:32 ` bug#38145: [PATCH 0/3] Add knot-resolver and knot-resolver-service-type 宋文武

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).