services: iwd: Simplify configuration serialization procedure.

* rosenthal/services/networking.scm (serialize-iwd-configuration): Simplify.
pull/2/head
Hilton Chain 12 months ago
parent 7944d2b25c
commit 1109aed83b
No known key found for this signature in database
GPG Key ID: ACC66D09CA528292
  1. 53
      rosenthal/services/networking.scm

@ -3,6 +3,8 @@
;; SPDX-License-Identifier: GPL-3.0-or-later ;; SPDX-License-Identifier: GPL-3.0-or-later
(define-module (rosenthal services networking) (define-module (rosenthal services networking)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module (guix records) #:use-module (guix records)
#:use-module (gnu packages dns) #:use-module (gnu packages dns)
@ -301,44 +303,23 @@ instead.")
list, power save will be disabled.")) list, power save will be disabled."))
(define (serialize-iwd-configuration config) (define (serialize-iwd-configuration config)
(mixed-text-file (apply mixed-text-file "main.conf"
"main.conf" (append-map
#~(string-append (match-lambda
"[General]\n" ((section . fields)
#$(serialize-configuration config (list "[" section "]\n"
(serialize-configuration
config
(filter-configuration-fields (filter-configuration-fields
iwd-configuration-fields iwd-configuration-fields
%iwd-config-general)) fields)))))
"[Network]\n" `(("General" . ,%iwd-config-general)
#$(serialize-configuration config ("Network" . ,%iwd-config-network)
(filter-configuration-fields ("Blacklist" . ,%iwd-config-blacklist)
iwd-configuration-fields ("Rank" . ,%iwd-config-rank)
%iwd-config-network)) ("Scan" . ,%iwd-config-scan)
"[Blacklist]\n" ("IPv4" . ,%iwd-config-ipv4)
#$(serialize-configuration config ("DriverQuirks" . ,%iwd-config-driver-quirks)))))
(filter-configuration-fields
iwd-configuration-fields
%iwd-config-blacklist))
"[Rank]\n"
#$(serialize-configuration config
(filter-configuration-fields
iwd-configuration-fields
%iwd-config-rank))
"[Scan]\n"
#$(serialize-configuration config
(filter-configuration-fields
iwd-configuration-fields
%iwd-config-scan))
"[IPv4]\n"
#$(serialize-configuration config
(filter-configuration-fields
iwd-configuration-fields
%iwd-config-ipv4))
"[DriverQuirks]\n"
#$(serialize-configuration config
(filter-configuration-fields
iwd-configuration-fields
%iwd-config-driver-quirks)))))
(define (add-iwd-config-file config) (define (add-iwd-config-file config)
`(("iwd/main.conf" `(("iwd/main.conf"

Loading…
Cancel
Save