mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
services: configuration: Fix interpose implementation.
* gnu/services/configuration.scm (interpose, serialize-text-config): Fix interpose implementation, move file-like object code to serialize-text-config. Signed-off-by: Oleg Pykhalov <go.wigust@gmail.com>
This commit is contained in:
parent
6e5ca0bb84
commit
7af3b82217
1 changed files with 11 additions and 5 deletions
|
@ -359,10 +359,7 @@ (define* (interpose ls #:optional (delimiter "\n") (grammar 'infix))
|
||||||
(G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.")
|
(G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.")
|
||||||
grammar)))
|
grammar)))
|
||||||
(fold-right (lambda (e acc)
|
(fold-right (lambda (e acc)
|
||||||
(cons #~(begin
|
(cons e
|
||||||
(use-modules (ice-9 rdelim))
|
|
||||||
(with-fluids ((%default-port-encoding "UTF-8"))
|
|
||||||
(with-input-from-file #$e read-string)))
|
|
||||||
(if (and (null? acc) (eq? grammar 'infix))
|
(if (and (null? acc) (eq? grammar 'infix))
|
||||||
acc
|
acc
|
||||||
(cons delimiter acc))))
|
(cons delimiter acc))))
|
||||||
|
@ -387,7 +384,16 @@ (define serialize-file-like empty-serializer)
|
||||||
(define (text-config? config)
|
(define (text-config? config)
|
||||||
(list-of file-like?))
|
(list-of file-like?))
|
||||||
(define (serialize-text-config field-name val)
|
(define (serialize-text-config field-name val)
|
||||||
#~(string-append #$@(interpose val "\n" 'suffix)))
|
#~(string-append
|
||||||
|
#$@(interpose
|
||||||
|
(map
|
||||||
|
(lambda (e)
|
||||||
|
#~(begin
|
||||||
|
(use-modules (ice-9 rdelim))
|
||||||
|
(with-fluids ((%default-port-encoding "UTF-8"))
|
||||||
|
(with-input-from-file #$e read-string))))
|
||||||
|
val)
|
||||||
|
"\n" 'suffix)))
|
||||||
|
|
||||||
(define ((generic-serialize-alist-entry serialize-field) entry)
|
(define ((generic-serialize-alist-entry serialize-field) entry)
|
||||||
"Apply the SERIALIZE-FIELD procedure on the field and value of ENTRY."
|
"Apply the SERIALIZE-FIELD procedure on the field and value of ENTRY."
|
||||||
|
|
Loading…
Reference in a new issue