[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#50967] [PATCH 13/14] home: services: configuration: Support file-li
From: |
Xinglu Chen |
Subject: |
[bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects. |
Date: |
Sat, 02 Oct 2021 20:35:40 +0200 |
On Sat, Oct 02 2021, Oleg Pykhalov wrote:
> * gnu/home/services/configuration.scm (interpose): Include content of files.
> (string-or-gexp?): Rename to 'file-or-string-or-gexp?' and check for file-like
> object.
I would call it ‘file-like-or-string-or-gexp?’, just ‘files’ doesn’t
really make it clear that it should be a “file-like object”.
> (serialize-string-or-gexp): Rename to 'serialize-file-or-string-or-gexp'.
> (text-config?): Call 'file-or-string-or-gexp?' intead of 'string-or-gexp?'.
> * guix/scripts/home/import.scm:
> (generate-bash-module+configuration): Don't call slurp-file-gexp.
> ---
> gnu/home/services/configuration.scm | 14 ++++++++++----
> guix/scripts/home/import.scm | 8 +++-----
> 2 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/gnu/home/services/configuration.scm
> b/gnu/home/services/configuration.scm
> index 5e7743e7d6..39db7a5693 100644
> --- a/gnu/home/services/configuration.scm
> +++ b/gnu/home/services/configuration.scm
> @@ -59,7 +59,12 @@ DELIMITER interposed LS. Support 'infix and 'suffix
> GRAMMAR values."
> (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.")
> grammar)))
> (fold-right (lambda (e acc)
> - (cons e
> + (cons (if (file-like? e)
> + #~(begin
> + (use-modules (ice-9 rdelim))
> + (with-fluids ((%default-port-encoding "UTF-8"))
> + (with-input-from-file #$e read-string)))
> + e)
> (if (and (null? acc) (eq? grammar 'infix))
> acc
> (cons delimiter acc))))
> @@ -79,11 +84,12 @@ the list result in @code{#t} when applying PRED? on them."
>
> (define alist? list?)
>
> -(define (string-or-gexp? sg) (or (string? sg) (gexp? sg)))
> -(define (serialize-string-or-gexp field-name val) "")
> +(define (file-or-string-or-gexp? fsg)
> + (or (string? fsg) (gexp? fsg) (file-like? fsg)))
> +(define (serialize-file-or-string-or-gexp field-name val) "")
This could defined as ‘empty-serializer’ from (gnu services
configuration).
>
> (define (text-config? config)
> - (and (list? config) (every string-or-gexp? config)))
> + (and (list? config) (every file-or-string-or-gexp? config)))
‘text-config?’ could be defined as (list-of file-or-string-or-gexp?)
> (define (serialize-text-config field-name val)
> #~(string-append #$@(interpose val "\n" 'suffix)))
>
> diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
> index c977ec3861..611f580e85 100644
> --- a/guix/scripts/home/import.scm
> +++ b/guix/scripts/home/import.scm
> @@ -46,17 +46,15 @@
> (home-bash-configuration
> ,@(if (file-exists? rc)
> `((bashrc
> - (list (slurp-file-gexp (local-file ,rc)))))
> + (list (local-file ,rc))))
> '())
> ,@(if (file-exists? profile)
> `((bash-profile
> - (list (slurp-file-gexp
> - (local-file ,profile)))))
> + (list (local-file ,profile))))
> '())
> ,@(if (file-exists? logout)
> `((bash-logout
> - (list (slurp-file-gexp
> - (local-file ,logout)))))
> + (list (local-file ,logout))))
> '()))))))
>
>
> --
> 2.33.0
signature.asc
Description: PGP signature
- [bug#50967] [PATCH 07/14] gnu: home-services: Move xdg to (gnu home services)., (continued)
- [bug#50967] [PATCH 07/14] gnu: home-services: Move xdg to (gnu home services)., Oleg Pykhalov, 2021/10/02
- [bug#50967] [PATCH 04/14] gnu: home-services: Move utils to (gnu home services)., Oleg Pykhalov, 2021/10/02
- [bug#50967] [PATCH 06/14] gnu: home-services: Move shells to (gnu home services)., Oleg Pykhalov, 2021/10/02
- [bug#50967] [PATCH 09/14] gnu: home-services: Move mcron to (gnu home services)., Oleg Pykhalov, 2021/10/02
- [bug#50967] [PATCH 10/14] scripts: home: (gnu home-services bash) -> (gnu home services bash)., Oleg Pykhalov, 2021/10/02
- [bug#50967] [PATCH 08/14] gnu: home-services: Move shepherd to (gnu home services)., Oleg Pykhalov, 2021/10/02
- [bug#50967] [PATCH 12/14] gnu: home-services: Update %service-type-path., Oleg Pykhalov, 2021/10/02
- [bug#50967] [PATCH 11/14] doc: (gnu home-services) -> (gnu home services)., Oleg Pykhalov, 2021/10/02
- [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects., Oleg Pykhalov, 2021/10/02
- [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects.,
Xinglu Chen <=
- [bug#50967] [PATCH 00/12] Move (gnu home-services XYZ) to (gnu services XYZ), Ludovic Courtès, 2021/10/04
- [bug#50967] file-like objects instead of gexps, Andrew Tropin, 2021/10/06
- [bug#50967] file-like objects instead of gexps, Ludovic Courtès, 2021/10/08
- [bug#50967] file-like objects instead of gexps, Andrew Tropin, 2021/10/08
- [bug#50967] file-like objects instead of gexps, Ludovic Courtès, 2021/10/09
- [bug#50967] file-like objects instead of gexps, Andrew Tropin, 2021/10/14
- [bug#50967] file-like objects instead of gexps, Xinglu Chen, 2021/10/08
- [bug#50967] file-like objects instead of gexps, Andrew Tropin, 2021/10/08
- [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects., Andrew Tropin, 2021/10/08
- [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects., Andrew Tropin, 2021/10/14