Toggle diff (207 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 974bfa3fb0..76bd1b1413 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -20361,6 +20361,10 @@ Networking Setup
@code{'iwd} if you require authenticated access for encrypted WiFi or Ethernet
networks.
+@item @code{log-configuration} (default: @code{(network-manager-log-configuration)})
+Logging configuration for NetworkManager.
+This is a @code{<network-manager-log-configuration>} record object.
+
@item @code{dns} (default: @code{"default"})
Processing mode for DNS, which affects how NetworkManager uses the
@code{resolv.conf} configuration file.
@@ -20412,6 +20416,45 @@ Networking Setup
@end table
@end deftp
+@deftp {Data Type} network-manager-log-configuration
+Available @code{network-manager-log-configuration} fields are:
+
+@table @asis
+@item @code{level} (type: maybe-network-manager-log-level)
+The default logging verbosity level. Valid values are (in increasing
+order of verbosity): @code{'off}, @code{'err}, @code{'warn},
+@code{'info}, @code{'debug} and @code{'trace}.
+
+@item @code{domains} (type: maybe-network-manager-log-domains)
+Log messages by topic. The value for this field is a list of
+@var{domains} or pairs of @var{domains} and @var{levels} where the valid
+values for @var{levels} are the same as those described in the ``level''
+field and @var{domains} are any of: @code{'platform}, @code{'rfkill},
+@code{'ether}, @code{'wifi}, @code{'bt}, @code{'mb}, @code{'dhcp4},
+@code{'dhcp6}, @code{'ppp}, @code{'wifi-scan}, @code{'ip4}, @code{'ip6},
+@code{'autoip4}, @code{'dns}, @code{'vpn}, @code{'sharing},
+@code{'supplicant}, @code{'agents}, @code{'settings}, @code{'suspend},
+@code{'core}, @code{'device}, @code{'olpc}, @code{'wimax},
+@code{'infiniband}, @code{'firewall}, @code{'adsl}, @code{'bond},
+@code{'vlan}, @code{'bridge}, @code{'dbus-props}, @code{'team},
+@code{'concheck}, @code{'dcb}, @code{'dispatch}, @code{'audit},
+@code{'systemd}, @code{'vpn-plugin}, @code{'proxy}, @code{'none},
+@code{'all}, @code{'default}, @code{'dhcp} and @code{'ip}. The log
+level can be overrided per-domain in a pair with a @var{level}.
+For example:
+@lisp
+(network-manager-log-configuration
+ (level 'warn)
+ (domains '(all (wifi . debug) (wifi-scan . off))))
+@end lisp
+
+@item @code{audit?} (type: maybe-boolean)
+Whether to send audit records to @command{auditd}.
+
+@end table
+@end deftp
+
+
@cindex Connman
@defvar connman-service-type
This is the service type to run @url{https://01.org/connman,Connman},
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 496ff0f0ec..33ff5e040f 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -78,7 +78,10 @@ (define-module (gnu services networking)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-43)
+ #:use-module (srfi srfi-171)
+ #:use-module (ice-9 format)
#:use-module (ice-9 match)
+ #:use-module (ice-9 string-fun)
#:use-module (json)
#:re-export (static-networking-service
static-networking-service-type)
@@ -164,10 +167,16 @@ (define-module (gnu services networking)
tor-hidden-service ; deprecated
tor-service-type
+ network-manager-log-configuration
+ network-manager-log-configuration?
+ network-manager-log-configuration-level
+ network-manager-log-configuration-domains?
+ network-manager-log-configuration-audit?
network-manager-configuration
network-manager-configuration?
network-manager-configuration-package
network-manager-configuration-shepherd-requirement
+ network-manager-configuration-log-configuration
network-manager-configuration-dns
network-manager-configuration-vpn-plugins
network-manager-service-type
@@ -1158,6 +1167,92 @@ (define-record-type* <modem-manager-configuration>
;;; NetworkManager
;;;
+(define-maybe boolean)
+
+;; See the logging section at
+;; <https://networkmanager.dev/docs/api/latest/NetworkManager.conf.html> for
+;; the list of valid values for the predicates below.
+(define (network-manager-log-level? x)
+ (memq x '(off err warn info debug trace)))
+
+(define (network-manager-log-domain? x)
+ (memq x '(platform rfkill ether wifi bt mb dhcp4 dhcp6 ppp wifi-scan ip4 ip6
+ autoip4 dns vpn sharing supplicant agents settings
+ suspend core device olpc wimax infiniband firewall adsl
+ bond vlan bridge dbus-props team concheck dcb dispatch
+ audit systemd vpn-plugin proxy
+ ;; Special NetworkManager domains:
+ none all default dhcp ip)))
+
+(define (network-manager-log-domains? x)
+ (every
+ (match-lambda
+ (((? network-manager-log-domain?) . (? network-manager-log-level?)) #t)
+ ((? network-manager-log-domain?) #t)
+ (_ #f))
+ x))
+
+(define (serialize-network-manager-log-level field-name value)
+ `(logging level ,(format #f "~:@(~a~)" value)))
+
+(define (serialize-network-manager-log-domains field-name value)
+ (define (uglify-domain-symbol x)
+ (string-replace-substring (symbol->string x) "-" "_"))
+
+ (define serialize-entry
+ (match-lambda
+ (((= uglify-domain-symbol domain) . value)
+ (format #f "~:@(~a:~a~)" domain value))
+ ((= uglify-domain-symbol domain)
+ (format #f "~:@(~a~)" domain))))
+
+ (let ((serialized-value (list-transduce (compose (tmap serialize-entry)
+ (tadd-between ","))
+ string-append value)))
+ `(logging domains ,serialized-value)))
+
+(define-maybe network-manager-log-level)
+(define-maybe network-manager-log-domains)
+
+;; This implicitly belongs to the INI "logging" section.
+(define-configuration network-manager-log-configuration
+ (level
+ maybe-network-manager-log-level
+ "The default logging verbosity level. Valid values are (in increasing
+order of verbosity): @code{'off}, @code{'err}, @code{'warn}, @code{'info},
+@code{'debug} and @code{'trace}.")
+
+ (domains
+ maybe-network-manager-log-domains
+ "Log messages by topic. The value for this field is a list of @var{domains}
+or pairs of @var{domains} and @var{levels} where the valid values for
+@var{levels} are the same as those described in the ``level'' field and
+@var{domains} are any of: @code{'platform}, @code{'rfkill}, @code{'ether},
+@code{'wifi}, @code{'bt}, @code{'mb}, @code{'dhcp4}, @code{'dhcp6},
+@code{'ppp}, @code{'wifi-scan}, @code{'ip4}, @code{'ip6}, @code{'autoip4},
+@code{'dns}, @code{'vpn}, @code{'sharing}, @code{'supplicant}, @code{'agents},
+@code{'settings}, @code{'suspend}, @code{'core}, @code{'device}, @code{'olpc},
+@code{'wimax}, @code{'infiniband}, @code{'firewall}, @code{'adsl}, @code{'bond},
+@code{'vlan}, @code{'bridge}, @code{'dbus-props}, @code{'team}, @code{'concheck},
+@code{'dcb}, @code{'dispatch}, @code{'audit}, @code{'systemd},
+@code{'vpn-plugin}, @code{'proxy}, @code{'none}, @code{'all}, @code{'default},
+@code{'dhcp} and @code{'ip}.
+
+The log level can be overrided per-domain in a pair with a @var{level}.
+For example:
+@lisp
+(network-manager-log-configuration
+ (level 'warn)
+ (domains '(all (wifi . debug) (wifi-scan . off))))
+@end lisp")
+
+ (audit?
+ maybe-boolean
+ "Whether to send audit records to @command{auditd}."
+ (serializer generic-ini-serialize-boolean)
+ (serializer-options `(#:section logging
+ #:field-name-transform ,(const 'audit)))))
+
;; TODO: deprecated field, remove later.
(define (warn-iwd?-field-deprecation value)
(when value
@@ -1181,6 +1276,18 @@ (define-configuration network-manager-configuration
networks."
empty-serializer)
+ (log-configuration
+ (network-manager-log-configuration (network-manager-log-configuration))
+ "Logging configuration for NetworkManager. This is a
+@code{<network-manager-log-configuration>} record object."
+ (serializer
+ (lambda (_ value)
+ ;; Wrap the serialization of the log-configuration which is a list
+ ;; of INI entries in a ‘ini-entries’ object.
+ (ini-entries (list-transduce
+ (base-transducer value) rcons
+ network-manager-log-configuration-fields)))))
+
(dns
(string "default")
"Processing mode for DNS, which affects how NetworkManager uses the
--
2.39.2