guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#50967] [PATCH 13/14] home: services: configuration: Support file-li


From: Andrew Tropin
Subject: [bug#50967] [PATCH 13/14] home: services: configuration: Support file-like objects.
Date: Fri, 08 Oct 2021 13:06:02 +0300

On 2021-10-02 19:38, 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.
> (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) "")
>  
>  (define (text-config? config)
> -  (and (list? config) (every string-or-gexp? config)))
> +  (and (list? config) (every file-or-string-or-gexp? config)))
>  (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))))
>                          '()))))))

I think this patch requires more discussion and better to keep it
outside of this patch series.  Skimmed throught other patches, overall
LGTM.

-- 
Best regards,
Andrew Tropin

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]