Subject: [bug#61956] [PATCH v3] services: dns: Extend dnsmasq-configuration.

From: Sergey Trofimov <[email-masked]>
Date: Fri, 10 Mar 2023 09:36:13 +0100

* gnu/service/dns.scm: (<dnsmasq-configuration>)[servers-file]: Add.
* doc/guix.texi: Document (<dnsmasq-configuration>)[servers-file].
---
 doc/guix.texi        | 3 +++
 gnu/services/dns.scm | 9 +++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 6671ba9305..f62af051ab 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -31502,6 +31502,9 @@ in @var{servers}.
 @item @code{servers} (default: @code{'()})
 Specify IP address of upstream servers directly.
 
+@item @code{servers-file} (default: @code{#f})
+Specify file containing upstream servers. This file is re-read when dnsmasq receives SIGHUP.
+
 @item @code{addresses} (default: @code{'()})
 For each entry, specify an IP address to return for any host in the
 given domains.  Queries in the domains are never forwarded and always
diff --git a/gnu/services/dns.scm b/gnu/services/dns.scm
index 32fb8c0664..7ff34babdc 100644
--- a/gnu/services/dns.scm
+++ b/gnu/services/dns.scm
@@ -754,6 +754,8 @@ (define-record-type* <dnsmasq-configuration>
                     (default #f))       ;boolean
   (servers          dnsmasq-configuration-servers
                     (default '()))      ;list of string
+  (servers-file     dnsmasq-configuration-servers-file
+                    (default #f))       ;string
   (addresses        dnsmasq-configuration-addresses
                     (default '()))      ;list of string
   (cache-size       dnsmasq-configuration-cache-size
@@ -792,7 +794,7 @@ (define (dnsmasq-shepherd-service config)
      port local-service? listen-addresses
      resolv-file no-resolv?
      forward-private-reverse-lookup? query-servers-in-order?
-     servers addresses
+     servers addresses servers-file
      cache-size negative-cache?
      cpe-id
      tftp-enable? tftp-no-fail?
@@ -827,6 +829,9 @@ (define (dnsmasq-shepherd-service config)
                  #$@(if query-servers-in-order?
                         '("--strict-order")
                         '())
+                 #$@(if servers-file
+                        (list (format #f "--servers-file=~a" servers-file))
+                        '())
                  #$@(map (cut format #f "--server=~a" <>)
                          servers)
                  #$@(map (cut format #f "--address=~a" <>)
@@ -848,7 +853,7 @@ (define (dnsmasq-shepherd-service config)
                         '("--tftp-single-port")
                         '())
                  #$@(if tftp-secure?
-                        '("--tftp-secure?")
+                        '("--tftp-secure")
                         '())
                  #$@(if tftp-max
                         (list (format #f "--tftp-max=~a" tftp-max))
-- 
2.39.2