GNU bug report logs - #38145
[PATCH 0/3] Add knot-resolver and knot-resolver-service-type.

Previous Next

Package: guix-patches;

Reported by: 宋文武 <iyzsong <at> member.fsf.org>

Date: Sat, 9 Nov 2019 09:18:02 UTC

Severity: normal

Tags: patch

Done: iyzsong <at> member.fsf.org (宋文武)

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38145 in the body.
You can then email your comments to 38145 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#38145; Package guix-patches. (Sat, 09 Nov 2019 09:18:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 宋文武 <iyzsong <at> member.fsf.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 09 Nov 2019 09:18:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 宋文武 <iyzsong <at> member.fsf.org>
To: guix-patches <at> gnu.org
Cc: 宋文武 <iyzsong <at> member.fsf.org>
Subject: [PATCH 0/3] Add knot-resolver and knot-resolver-service-type.
Date: Sat,  9 Nov 2019 17:16:28 +0800
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




Information forwarded to guix-patches <at> gnu.org:
bug#38145; Package guix-patches. (Sat, 09 Nov 2019 09:21:02 GMT) Full text and rfc822 format available.

Message #8 received at 38145 <at> debbugs.gnu.org (full text, mbox):

From: 宋文武 <iyzsong <at> member.fsf.org>
To: 38145 <at> debbugs.gnu.org
Cc: 宋文武 <iyzsong <at> member.fsf.org>
Subject: [PATCH 1/3] gnu: Add python-breathe.
Date: Sat,  9 Nov 2019 17:19:54 +0800
* 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





Information forwarded to guix-patches <at> gnu.org:
bug#38145; Package guix-patches. (Sat, 09 Nov 2019 09:21:02 GMT) Full text and rfc822 format available.

Message #11 received at 38145 <at> debbugs.gnu.org (full text, mbox):

From: 宋文武 <iyzsong <at> member.fsf.org>
To: 38145 <at> debbugs.gnu.org
Cc: 宋文武 <iyzsong <at> member.fsf.org>
Subject: [PATCH 2/3] gnu: Add knot-resolver.
Date: Sat,  9 Nov 2019 17:19:55 +0800
* 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





Information forwarded to guix-patches <at> gnu.org:
bug#38145; Package guix-patches. (Sat, 09 Nov 2019 09:21:03 GMT) Full text and rfc822 format available.

Message #14 received at 38145 <at> debbugs.gnu.org (full text, mbox):

From: 宋文武 <iyzsong <at> member.fsf.org>
To: 38145 <at> debbugs.gnu.org
Cc: 宋文武 <iyzsong <at> member.fsf.org>
Subject: [PATCH 3/3] services: Add knot-resolver-service-type.
Date: Sat,  9 Nov 2019 17:19:56 +0800
* 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))))))
 
 
+;;;
+;;; 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.")))
+
+
 ;;;
 ;;; Dnsmasq.
 ;;;
-- 
2.19.2





Reply sent to iyzsong <at> member.fsf.org (宋文武):
You have taken responsibility. (Mon, 11 Nov 2019 12:34:01 GMT) Full text and rfc822 format available.

Notification sent to 宋文武 <iyzsong <at> member.fsf.org>:
bug acknowledged by developer. (Mon, 11 Nov 2019 12:34:02 GMT) Full text and rfc822 format available.

Message #19 received at 38145-done <at> debbugs.gnu.org (full text, mbox):

From: iyzsong <at> member.fsf.org (宋文武)
To: 38145-done <at> debbugs.gnu.org
Subject: Re: [bug#38145] [PATCH 0/3] Add knot-resolver and
 knot-resolver-service-type.
Date: Mon, 11 Nov 2019 20:32:45 +0800
宋文武 <iyzsong <at> 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 :-)




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 10 Dec 2019 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 132 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.