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. 57
      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"
(filter-configuration-fields (serialize-configuration
iwd-configuration-fields config
%iwd-config-general)) (filter-configuration-fields
"[Network]\n" iwd-configuration-fields
#$(serialize-configuration config fields)))))
(filter-configuration-fields `(("General" . ,%iwd-config-general)
iwd-configuration-fields ("Network" . ,%iwd-config-network)
%iwd-config-network)) ("Blacklist" . ,%iwd-config-blacklist)
"[Blacklist]\n" ("Rank" . ,%iwd-config-rank)
#$(serialize-configuration config ("Scan" . ,%iwd-config-scan)
(filter-configuration-fields ("IPv4" . ,%iwd-config-ipv4)
iwd-configuration-fields ("DriverQuirks" . ,%iwd-config-driver-quirks)))))
%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